0
我已經在我的Rails 3應用程序下面的代碼,它應該被顯示一個選擇框,每個asset_type
記錄:在Rails 3中選擇菜單?
assets_helper
def asset_type_all_select_options
asset_type.all.map{ |asset_type| [asset_type.name, asset_type.id] }
end
_form.html.erb(資產)
<%= f.select :asset_type_id, asset_type_all_select_options, :class => "input-text", :prompt => '--Select-----' %>
,這裏是我的模型:
asset.rb
belongs_to :asset_type
asset_type.rb
has_many :assets
使用上面的代碼中,我得到以下錯誤:
undefined local variable or method `asset_type' for #<#<Class:0x007f87a9f7bdf8>:0x007f87a9f77d48>
難道我做錯了什麼?這種方法不適用於雙桶型號名稱嗎?任何指針將不勝感激!