Any tutorials for rails design patterns?

any Design patterns of rails development ?

Ruby on Rails itself - as the name suggests - is full of design patterns, it is opinionated:

1 Like

Although trying to bolt on a design pattern for the hell of it is the exact wrong approach, there is an authentication pattern that crops up repeatedly: the null object pattern.

It’s common in Rails apps to have a current_user method that returns nil when the user is not authenticated. This often results in view code like <%= current_user ? current_user.name : 'Guest' %> throughout the app. It’s often better to have current_user return a GuestUser that responds to the same methods as User . That makes the view code simply <%= current_user.name %>.

1 Like