Ruby on Rails
Tuesday, November 26, 2013
I have fixed this issue. The 'match' statement needs to be outside the resource block in routes.rb. Rest everything remains the same.
Thanks.
Sent from Galaxy R, please ignore typo or brevity
On Nov 27, 2013 3:41 AM, "Ankur" <specialankur@gmail.com> wrote:
-- --I have home.html.erb file which has a link for course.html.erb file using link_to. I have defined a named route for this navigation. On clicking the link, I get an error as shown below. Looks like the named route is not accessible in the view.Is my routes.rb entry correct? I am not sure if after match in routes.rb file, the name of view should be in single quotes or double quotes and whether a "/" is needed before view name. I tried both, it didn't work.Error:undefined local variable or method `training_path' for #<#<Class:0xa856f9c>:0xa857244>
----views/trainer/home.html.erb
<li> <%= link_to "Training", training_path %> </li>
routes.rb
resources :trainer do match "/course", to: 'trainer#course', :as => :training end
controller/trainer_controller.rb
class TrainerController < ApplicationController
def course end
end
views/trainer/course.html.erb
<h1> Learning Ruby </h1>
rake routes shows me following line related to the route:
trainer_training /trainer/:trainer_id/course(.:format) trainer#course
Thanks.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/10f2ce62-4b20-4d29-a89d-56391a0f3b38%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALSL1eMVDqf9YF8idsbN8oC3K%3DkeQ1%3D6VT_1U5weTgv7teCXUg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment