Sunday, 15 July 2012

ruby - rails devise how to specify view/controller action need sign in -



ruby - rails devise how to specify view/controller action need sign in -

i can

if not user_signed_in? redirect_to new_user_session_path

for each action need authentication. imagine there should more elegant way so.

thanks

add before_filter :authenticate_user! in controllers should have user authentication.

reference: https://github.com/plataformatec/devise#controller-filters-and-helpers

if not actions in controller require user authentication, implement custom before filter explained in http://stackoverflow.com/a/6034498/429758

if whole application needs user authentication, above line belongs in app/controllers/application_controller.rb file.

ruby ruby-on-rails-3 devise

No comments:

Post a Comment