Rails の link_to 関数にいくつかの機能を追加する関数を作成しようとしています。私がやりたいことは、単にクラスを追加することです。私がこれまでに持っているもの:
#application_helper.rb
def button_link(*args)
link_to(*args.push(class: 'btn'))
end
問題は、別のクラスを button_link 関数に追加すると機能しないことです。
例:
<td class='button'>
<%= button_link "Show", category_path(item), class: "btn-primary" %>
</td>
次のエラーが表示されますwrong number of arguments (4 for 3)
。どうすればこれを正しく行うことができますか?