Search code examples
ruby-on-railserbstart-page

How do you get a Rails project to start with index.html.erb instead of index.html?


My index.html page for my project needs some Ruby code so I need to change it to a .erb extension. How do I configure Rails to identify the index.html.erb file as the starting page of the project instead of the index.html file?


Solution

  • You need to configure the map.root path in your config/routes.rb file.

    map.root :controller => "blogs"
    
    # This would recognize http://www.example.com/ as
    params = { :controller => 'blogs', :action => 'index' }
    
    # and provide these named routes
    root_url   # => 'http://www.example.com/'
    root_path  # => ''
    

    http://api.rubyonrails.org/classes/ActionController/Routing.html