ruby-on-railsruby-on-rails-4routescomfortable-mexican-sofa

How do I set root path to '/' without controller and action in Rails?


In my routes.rb I want to set the root_path to '/' without specifying any controller or action. Is that possible?

I tried root to: '/' but it's complaining, that no controller or action is specified.

Updated Info:

I'm using the comfortable-mexican-sofa CMS, and my root_path should go to the cms root path.

At the moment I'm just using redirect_to '/' in my controllers and this is working, but I thought it would be nicer to use root_path.


Solution

  • Try

    root :to => "cms/content#show"
    

    From the docs: https://github.com/comfy/comfortable-mexican-sofa/wiki/Pages

    The first page you create is the homepage, and therefore you cannot specify a slug. By default, you should be able to access the homepage without specifying your root route. However, if you or a gem you are using need access to the root_path helper, specify root :to => "cms/content#show" in your routes.