我正在尝试在 Rails 中创建一个下拉框,但出现错误,我希望有人可以解释原因。
这是错误:
undefined method `bot_id' for #<Robot:0x007fa1d663cac0>
机器人类:
class Robot < ActiveRecord::Base
attr_accessible :color1, :color2, :image, :name, :speed, :weapon_damage, :weapon_slots, :bot_id
ROBOT_TYPES = Hash.new("Mini Bot" => "1", "Micro Bot" => "2", "Macro Bot" => "3")
....
end
形式:
...
<div class="field">
<%= f.label :bot_id %><br />
<%= f.select :bot_id, Robot::ROBOT_TYPES%>
</div>
...