Re:10 Most Common Rails Mistakes
by 3pt14159 on Tuesday June 03, 2014 @01:49PM
(#7841682)
I disagree.
Generally you will have sections of your app that are only for logged in users, so your ACL logic in your controller handily takes care of that, while still giving you the convenience of being able to call current_user and know that you actually have a user, while still being able to say things like `if current_user` where you need it.
I do like your render partial example, but in most cases you will want to be doing something like showing a like button if the user is signed in, in which case you can do:
<%= render partial: current_user %>
And if the current_user is nil the partial will just be skipped.
Re:10 Most Common Rails Mistakes
by awj on Tuesday June 03, 2014 @02:37PM
(#7841987)
I'm not sure I understand your point. If your controller logic ensures that users will always be logged in, why would you need to test for the presence of current_user?
Generally you will have sections of your app that are only for logged in users, so your ACL logic in your controller handily takes care of that, while still giving you the convenience of being able to call current_user and know that you actually have a user, while still being able to say things like `if current_user` where you need it.
I do like your render partial example, but in most cases you will want to be doing something like showing a like button if the user is signed in, in which case you can do:
And if the current_user is nil the partial will just be skipped.