您好我有以下collection_select标签:
<%=collection_select(:post, :applicant_id, Room.all, :room_number, :room_number, {selected: @applicant.room_number}, { :onchange=>"window.location='#{room_select_path(@applicant.id)}?room_number=' + this.value"})%>
目前,它显示所有可用的房间实体。
我想要做的是显示具有属性的所有房间实体:room_type。
答案 0 :(得分:1)
试试这个
<%=collection_select(:post, :applicant_id, Room.where(room_type: "your_type_value"), :room_number, :room_number, {selected: @applicant.room_number}, { :onchange=>"window.location='#{room_select_path(@applicant.id)}?room_number=' + this.value"})%>