<%=link_to "link", {:controller=>:hoge_controller,:action=>:hoge_action}, class: "hoge_class"%>
↓
<%=link_to{:controller=>:hoge_controller,:action=>:hoge_action}, class:"hoge_class" do%>
<span>hoge</span> link.
<%end%>
This will result in an error.
<%=link_to hoge_path, class:"hoge_class" do%>
<span>hoge</span> link.
<%end%>
There is no problem with this, but how do I explicitly specify the controller and actions?
ruby-on-rails ruby erb
link_to
arguments can be enclosed in parentheses.
<%=link_to({:controller=>:hoge_controller,:action=>:hoge_action}, class:"hoge_class")do%>
<span>hoge</span> link.
<%end%>
© 2024 OneMinuteCode. All rights reserved.