Last active
October 5, 2015 13:38
-
-
Save RohitRox/2814084 to your computer and use it in GitHub Desktop.
Setting layouts and helper to access control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in helper/application_helper.rb | |
def authorize_resources | |
unless user_signed_in? | |
redirect_to new_user_session_path | |
end | |
end | |
#in application_controller | |
include ApplicationHelper | |
#layout fix | |
layout :layout_by_resource | |
def layout_by_resource | |
if devise_controller? && resource_name == :user && action_name == 'new' | |
"devise" | |
else | |
"application" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment