Skip to content

Instantly share code, notes, and snippets.

@RohitRox
Last active October 5, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RohitRox/2814084 to your computer and use it in GitHub Desktop.
Save RohitRox/2814084 to your computer and use it in GitHub Desktop.
Setting layouts and helper to access control
#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