Rails 3アプリケーションに次のコードがあります。各asset_type
レコードで選択ボックスを表示することになっています:
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>
私は何か間違ったことをしていますか?この方法は、二重バレルのモデル名では機能しませんか? 任意のポインタをいただければ幸いです!