devise
devise copied to clipboard
View helper methods
If/Else conditional statements based on a users session status are relatively common at the controller and view level of applications. These conditional statements are repetitive, accumulate quickly and make our code bulky . Great programs are DRY and this pull request seeks to DRY up our code by creating helper methods that abstract if/else conditionals into methods where a block is called based on a resources sign_in/out state.
Examples:
View ->
user_signed_out do <%= link_to "Sign In", new_user_session_path %> end
Controller ->
def some_action; admin_signed_in { render @posts }; admin_signed_out { redirect_to root_path }; end