I am following this routing tutorial for Ruby on Rails:
http://guides.rubyonrails.org/routing.html
It says that when I need to create a new url, I should make a route for it. So I did that.
I would like to have a url like this http://www.domain.com/fomats/formats.html.rb so I did something like this in the routes.rb file:
resources :formats
get "formats/index" #display all formats
Is that correct? For my index route, I also have something like this in my route.rb file: root :to => “home#index” – should I have something like this in the formats route?
Also, how do I create the actual controller? Do I make it by hand, or does rails somehow create the stub of it for me?
Right now I get this error:
missing :action
Does that mean I am missing the controller or something else?
Thanks,
Alex
As others have said, you should probably continue studying with other books or resources. These fundamental questions you are asking may become more clear the more you read.
Here are some quickfire hints that hopefully help you.
—
When you declare this in the routes.rb file:
You automatically get the following declaration for free, so you don’t have to re-declare it:
—
URL’s in rails look like this:
That URL would map to “formats#index”
—
To see what explicit routes have been generated, run this in your rails root directory:
—
To create a controller: