Rails beginner
Rails beginner

Reputation: 14504

Rails link to help

Here is my routes:

match '/:kategoris/:id' => 'konkurrancers#show', :as => 'konkurrance'
match '/:id' => 'kategoris#show'

I am using friendly url.

My routes works perfectly.

The problem is it dont know how I link to them:

I have tried this in my root view:

<% @konkurrencer.each do |vind| %>
<li><%= vind.name %></li>
<li><%= link to "vind.name", konkurrance_path(vind.cached_slug) %></li>
 <% end %>

I get the following error:

No route matches {:controller=>"konkurrancers", :action=>"show", :kategoris=>"horoskoptesten-hvad-siger-stjernerne-om-dig"

horoskoptesten-hvad-siger-stjernerne-om-dig is a konkurrance

Instead I would like the link to be: {:controller=>"konkurrancers", :action=>"show", :kategoris => "vind-rejse" :id=>"horoskoptesten-hvad-siger-stjernerne-om-dig">

Upvotes: 0

Views: 118

Answers (2)

Nick Hammond
Nick Hammond

Reputation: 11419

Run "rake routes" to display the details of all of your current routes.

Upvotes: 0

Shiv
Shiv

Reputation: 8412

I think you need to pass in 2 paarmeters when you use link to.

<li><%= link to "vind.name", konkurrance_path(vind.name,vind.cached_slug) %></li>

Upvotes: 1

Related Questions