Is there a way to add class by default in a link_to helper? This global setting should prevent me manually adding the :class option everytime.
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" %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.