开发者

ROR link_to parameters

in routes.rb I have such a line

resources :ideas

and in a view I have:

<%= link_to 'My ideas',ideas_path+'?id=my' %>
<%= link_to 'My ideas',ideas_path, :id=>'my' %>

first line opens: http://localhost:2000开发者_开发百科/ideas?id=my while the second opens: http://localhost:2000/ideas

How to fix the second line? Bye


<%= link_to 'My ideas',ideas_path(:id=>'my') %>


Rails paths sort out your paramaters for you.

To link to a single 'idea' you could do something like ...

<%= link_to 'One idea',idea_path(@idea) %>

To link to all your 'ideas' then

<%= link_to 'All ideas',ideas_path %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜