I recently started to mess around with Rails again and wanted to see what’s up with Rails4. I created my project using composer ( using bootstrap,haml,rails4 ) and created a simple scaffold.
When I fired up the rails server and tried to visit my scaffold page I got the following error: “undefined local variable or method `root_path'”. The error was in one of the layout templates where it referenced the root_path. I googled around a bit for the specific error with no luck. Then tried the search “rails4 root_path”. Seems like its no longer defined as a route by default. You have to do the following to get it to work:
- Open routes.rb
- add a route like the following
root :to => "controller#action"
Hope this helps others!