Benito Serna Tips and tools for Ruby on Rails developers

User-centric Routing with Devise and Rails

July 7, 2012

Maybe there is a lot of people know this solution, but before today I didn’t know it, so I want to share this =).

Imagine that you want that the home page of your app for an authenticated user, to be a Dashboard with stadistics or something special, but you want to have an informative page for the people that is not authenticated.

With Devise you can solve this problem beautifully =)

authenticated do
  root :to => 'users#home'
end

root :to => 'pages#home'

Related articles

Weekly tips and tools for Ruby on Rails developers

I send an email each week, trying to share knowledge and fixes to common problems and struggles for ruby on rails developers, like How to fetch the latest-N-of-each record or How to test that an specific mail was sent or a Capybara cheatsheet. You can see more examples on Most recent posts or All post by topic.