pro*_*ati 3 html css ruby ruby-on-rails ruby-on-rails-3.1
任何人都知道您是否可以为禁用或当前链接分配标签和类别?下面的示例仅在浏览器中显示为当前链接的纯文本。
我有一些 rails 代码显示数据库中每个设计的按钮列表。
<% @id_cards.each do |id| %>
<%= link_to_unless_current id.design_type, id_card_design_path(id.id), :class => 'btn' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
活动链接被分配了正确的类并显示为按钮。
link_to_unless_current
接受一个可用于覆盖默认行为的块。
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to_unless_current
<%=
link_to_unless_current("Comment", { :controller => "comments", :action => "new" }) do
link_to("Go back", { :controller => "posts", :action => "index" })
end
%>
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,如果当前页面是“新评论”页面,它将产生“返回”链接。
归档时间: |
|
查看次数: |
2740 次 |
最近记录: |