【发布时间】:2013-05-20 07:24:29
【问题描述】:
我正在制作一个管理员可以更改主题的网络应用程序。所以我有 2 个 css 文件,style.css 和 style2.css。 在我的 application_helper 我有
def set_themes(themes)
@themes = themes
end
在 application_controller 我有
helper_method :themes
我把它放在 application.html.erb 上
<%= stylesheet_link_tag set_themes %>
在 Admin 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。我知道问题在于我如何使用 onchange,因为当我从 application_helper 手动更改时,它可以工作。但我不知道如何通过单击 select_tag 从 application_helper 调用方法。
谁能帮帮我?谢谢你:-)
【问题讨论】:
-
你能给出
ArgumentError异常的完整回溯和文本吗? -
参数数量错误(0 代表 1)
-
谢谢,请看下面的回答
-
非常感谢您的快速回复 :-)
标签: css ruby-on-rails-3 themes onchange html-select