模型关系如下
class Room < ActiveRecord::Base
has_many :equipments
end
class Equipment < ActiveRecord::Base
belongs_to :room
end
如下图所示,希望在选择检查诊室后,根据当前选择诊室获取检查设备信息
如何获取 select 中当前选中项的 value?
<%= select_tag :room_id, options_for_select(Dept.find_by(dept_id:@deptid).rooms.collect { |room| [room.room_name, room.id]}) %>