Matthew Rathbone
Matthew Rathbone

Reputation: 8259

Why am I getting this 'no route matches' error on a link_to? I have the route defined! (Rails)

so I have this code:

link_to 'text', :copy_job, :id => 1

which matches this route definition:

match 'hive_jobs/copy/:id' => 'hive_jobs#copy', :as => :copy_job

and if I browse to the page /hive_jobs/copy/1 it works

But the link_to throws the following exception:

No route matches {:action=>"copy", :controller=>"hive_jobs"}

Why?

Upvotes: 0

Views: 81

Answers (1)

Dylan Markow
Dylan Markow

Reputation: 124419

Try link_to 'text', copy_job_path(1)

Upvotes: 2

Related Questions