开发者

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=>"horoskopte开发者_开发知识库sten-hvad-siger-stjernerne-om-dig">


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>


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜