管理者がテーマを変更できる Web アプリを作成しています。したがって、style.css と style2.css の 2 つの css ファイルがあります。私のapplication_helperには
def set_themes(themes)
@themes = themes
end
私が持っているapplication_controllerで
helper_method :themes
そして、これをapplication.html.erbに置きます
<%= stylesheet_link_tag set_themes %>
そして、管理者の index.html で、次のように select_tag を記述します。
Choose themes: <%= select_tag(:themes, options_for_select({"Black" => "compiled/styles", "Green" => "compiled/styles2"}), :onchange => 'set_themes(this.options[this.selectedIndex].value)') %>
そして、私は得ArgumentError
ました。application_helper から手動で変更すると機能するため、onchange の使用方法に問題があることはわかっています。しかし、select_tag をクリックして application_helper からメソッドを呼び出す方法がわかりません。
誰でも私を助けることができますか?ありがとう :-)