Rails - Devise - How to Handle Landing Pages Versus App Pages
I have a Rails 3 App.
When the use开发者_开发技巧r is not signed in... I want devise to show non-signed in pages: SignIn, register, about us, blog etc...
When a user is signed in I want it to go to the web app
where do I make this switch and how do I set it up? thanks
This is easy! I just finished a Rails 3 app with devise, so my pain can be your gain. Just include the before_filter
at the beginning of the controllers you want to protect. Let's use the example of a Videos controller:
class VideosController < ApplicationController
before_filter :authenticate_user!
# all your actions go here: index, new, create, etc #
end
You can also pick and choose what actions in the controller are filtered:
class VideosController < ApplicationController
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
# all your actions go here: index, new, create, etc #
end
Devise gives you the authenticate_user!
method, and redirects for you.
精彩评论