将类添加到 link_to 会破坏链接 [英] adding a class to a link_to is breaking the link
本文介绍了将类添加到 link_to 会破坏链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 RoR 3 中使用了 link_to
I'm using link_to in RoR 3
当我这样使用它时,它工作正常:
When I use it like this, it works fine:
<%= link_to "Add to your favorites list",:controller =>
'favourite_companies', :action =>'create',
:company_id=>"#{@company.id}",
:company_name=>"#{@company.company_name}" %>
但是我也想通过一门课
但是,这对我不起作用.该课程有效,但它断开了链接.有什么想法吗?
however, this is not working for me. The class works, but it breaks the link. Any ideas?
<%= link_to "Add to your favorites list",{:controller =>
'favourite_companies', :action =>'create'},
:company_id=>"#{@company.id}",
:company_name=>"#{@company.company_name}",
:class=>"ui-button-text button_text"} %>
推荐答案
<%= link_to "Add to your favorites list",{:controller =>
'favourite_companies', :action =>'create'},
:company_id=>"#{@company.id}",
:company_name=>"#{@company.company_name}",
:class=>"ui-button-text button_text"} %>
试试这个
<%= link_to "Add to your favorites list", :controller =>
'favourite_companies', :action =>'create',
:company_id=>"#{@company.id}",
:company_name=>"#{@company.company_name}",
{ :class=>"ui-button-text button_text" } %>
因为 :class 应该在 :html_options 中(参考 API)
Since the :class should be in :html_options (refering to API)
link_to(body, url, html_options = {})
这篇关于将类添加到 link_to 会破坏链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文