Rails link_to 分配类和 id [英] Rails link_to assigning class and id
本文介绍了Rails link_to 分配类和 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%= link_to event do %>
#bunch of stuff making up the partial.
<% end %>
所以我试图为部分中的每个项目分配一个 ID 和一个类.我已经看到您必须在何处调用完整的 link_to
函数,例如 <%= link_to event, { controller: :controller, action:: :action }, {class: 'someClass',id: 'someId' } %>
.
So I'm trying to assign an ID and a class to each item in a partial. I've seen where you have to call the full link_to
function like <%= link_to event, { controller: :controller, action: :action }, {class: 'someClass', id: 'someId' } %>
.
这对我不起作用,因为 do 块,我想?想法?
That's not working for me, because of the do block, methinks? Ideas?
推荐答案
这对您有用吗?
<%= link_to event, id: "an-id", class: "some-class" do %>
#bunch of stuff making up the partial.
<% end %>
这篇关于Rails link_to 分配类和 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文