sebi
sebi

Reputation: 837

How can I configure my route.rb page to redictect to a view

In my route.rb file I currently have:

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
  map.root :controller => "test"

how do I direct my index page to direct to something like this: http://site.com/railstest/test/index.html

or just: http://site.com/railstest/test.erb

originally it started off at: http://site.com/railstest/

which took me to the default html page, which has now been deleted. should I change the route or create a test.rb in the view folder, thank you

Upvotes: 0

Views: 67

Answers (1)

Taryn East
Taryn East

Reputation: 27747

It's not possible to make a route that goes directly to a view, bypassing every controller.

So you have two options available to you now:

  1. make it as a static html page

    • create the full html page
    • save it in /public/railstest/filename.html
    • use the URL: site.com/railstest/filename.html
    • note: hard to maintain, and cannot take advantage of layouts.
  2. create a controller that will serve your view

    • either "script/generate RailstestController index" of "rails g PagesController index"
    • delete the app/views/index.html.erb that it creates and copy yourview file to that name instead
    • should Just Work

Upvotes: 1

Related Questions