我的select
无法正常工作并抛出此错误:
undefined local variable or method `marketplace_listing'
for #<#<Class:0x007fe2a496e950>:0x007fe2920faf38>
我在视图中的表单中有select
。
<%= f.select :marketplace, grouped_options_for_select(marketplace_listing),
{}, {prompt: "Select your Marketplace",
class: "icon_prefix input-field input-bottom-fixed down"}, required: true %>
marketplace_listing
是我定义的辅助方法,如下所示:
module MarketplaceHelper
def marketplace_listing
{
"North America" => [
['Canada', 'A2EUQ1WTGCTBG2'],
['Mexico', 'A1AM78C64UM0Y8'],
['United States', 'ATVPDKIKX0DER']
],
"Europe" => [
['France', 'A13V1IB3VIYZZH'],
['Germany', 'A1PA6795UKMFR9'],
['Italy', 'APJ6JRA9NG5V4'],
['Spain', 'A1RKKUPIHCS9HS'],
['United Kingdom', 'A1F83G8C2ARO7P']
]
}
end
end
我哪里出错了?
答案 0 :(得分:2)
在适当的控制器中包含帮助程序
class YourController < ApplicationController
helper MarketplaceHelper
...
end