开发者

How do I have two home pages, one for logged in users and one for everyone else, both at the root path?

开发者 https://www.devze.com 2023-01-19 10:49 出处:网络
I have a Pages controller, with an action/view called home. I have set this as the root of the site with

I have a Pages controller, with an action/view called home. I have set this as the root of the site with

map.root :controller => "pages", :action => "home"

At the moment, I am using this page as part of the logged in user's workflow, thus it is required for the user to be logged in to see it.

But I also need the root path to se开发者_如何学Pythonrve as the landing page for new users, with signup links/promotional stuff etc. Is this a good idea? Should I not be using it the way I am (as part of the logged in user's workflow)? Is the best way to do it just to do a check to see if there's a logged in user, and change the display appropriately?

Thanks for reading.


It's a personal preference, but I'd say the root page should be viewable by non-authenticated users. You could then have a before filter on the root page to redirect to the logged in user's home page if there is a current_user.


You can redirect the user to another action based on their login status. Or you can create two views, and render the appropriate one:
render :template => 'logged_in'

0

精彩评论

暂无评论...
验证码 换一张
取 消