Error while using a Named Route for naivgation

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

  • <%= link_to "Training", training_path %>
  • 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

    Learning R.

    On 26/11/2013, at 6:13 AM, Ankur K. [email protected] wrote:

    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

  • <%= link_to "Training", training_path %>
  • This would be better asked on a ‘Ruby on Rails’ forum.

    Try rake routes in your terminal. This will list your routes and show if
    you have missed any arguments.

    Henry

    REMOVE ME