[英]Ruby on rails link_to global class?
有沒有一種方法可以默認在link_to幫助器中添加類? 這個全局設置應該阻止我每次手動添加:class選項。
application_helper.rb
def nav_link(text, controller, action="index", class)
link_to_unless_current text, :id => nil,
:action => action,
:controller => controller,
:class => class
end
Views.html.erb
<%= nav_link "text", "controller", "action", "MYCLASS" %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.