Is it OK to put custom logic in routes.rb?
For example:
unless current_user
root :to => anonymous_page
else
root :to => logged_in_page
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can put custom logic into routes… but as avenger suggested – “current_user” won’t work due to when the routes file is loaded. We sometimes use logic in our routefile (eg setting up routes that are only available if RAILS_ENV == ‘development’).
What you probably want is a before_filter on “anonymous_page” eg: