Routing Error

Generated a controller "rails generate controller say" and then added a method to id named hello as. def hello end                             Made a file /app/view/say/hello.html.erb as "sudo gedit hello.html.erb" and add follwoing to it

<html> <head> <title>Hello, Rails!</title> </head> <body> <h1>Hello from Rails!</h1> </body> </html>

                            Browse to locahost:3000/say/hello gives the error Routing Error No route matches "/say/hello.html.erb"

Amrit pal

Please somebody help me.

It looks like you were trying to access “/say/hello.html.erb” as the URL rather than “say/hello”

Generated a controller "rails generate controller say" and then added a method to id named hello as.

You need to add a route to the action. Colin discussed this with you at some length last week.

Fred

Yes he discussed ,but thats was only if i want to see hello action at "localhost:3000". But to see hello method at "localhost: 3000/say/hello" doesn't need any routing settings.Still it is not showing it Why?

Thanks

Yes it does. Go and read the Rails Guide on routing again.

Colin

ok .Done    " root :to => "say#hello"". Still unsussess.      No route matches "/say/hello"

Thank you.

amritpal p. wrote in post #995099:

ok .Done "root :to => "say#hello"". Still unsussess. No route matches "/say/hello"

Thank you.

Quoted from the Rails guide: "You should put the root route at the end of the file. You also need to delete the public/index.html.erb file for the root route to take effect."

Rails will look in app/controllers for a controller named 'say_controller'. Inside that, it will search for an action with the name 'hello' and then will render that action using hello.html.erb in app/views/say

If it is not doing this, then there is something you've omitted when trying to explain the issue.

What is the output of rake routes?

What happens if you match 'say', :to => 'say#hello' and navigate your browser to /say?

Please see the following screencasts for routing in Rails 3.x:

> amritpal p. wrote in post #995099:

> ok .Done > "root :to => "say#hello"". Still unsussess. > No route matches "/say/hello"

> Thank you.

Quoted from the Rails guide: "You should put the root route at the end of the file. You also need to delete the public/index.html.erb file for the root route to take effect."

         it helped.but without deleting that file and setting routing path to say controller "localhost:3000/say/hello" wasn't work?i think it should work

Rails will look in app/controllers for a controller named 'say_controller'. Inside that, it will search for an action with the name 'hello' and then will render that action using hello.html.erb in app/views/say

If it is not doing this, then there is something you've omitted when trying to explain the issue.

What is the output of rake routes?

What happens if you match 'say', :to => 'say#hello' and navigate your browser to /say?

               it said " No route matches "/say/hello"".     Thanks

amritpal p. wrote in post #995108:

the root route to take effect."

it helped but without deleting that file and setting routing path to say controller "localhost:3000/say/hello" wasn't work? i think it should work

What happens if you match 'say', :to => 'say#hello' and navigate your browser to /say?

it said " No route matches "/say/hello"". Thanks

Please paste your routes.rb file here or use http://pastie.org/ if it's too long.

Age::Application.routes.draw do   # The priority is based upon order of creation:   # first created -> highest priority.

  # Sample of regular route:   # match 'products/:id' => 'catalog#view'   # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:   # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase   # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):   # resources :products

  # Sample resource route with options:   # resources :products do   # member do   # get 'short'   # post 'toggle'   # end

amritpal p. wrote in post #995117:

Please paste your routes.rb file here or use http://pastie.org/ if it's too long.

Age::Application.routes.draw do root :to => "say#hello" # See how all your routes lay out with "rake routes" end

Amrit pal

What is the output of rake routes? This will show you "how all your routes lay out".