我需要从f.association
中获得一个simple_form
形式的值。这将从控制器获得它的值,并传输所有的房间,我需要这个值来加载引导5模式,我需要重新加载所选房间的信息。
模型工作,但我需要占用set_parms
,以获得数据。
你能给我点主意或者怎么做吗?
这是我现有的代码:
表格
<%= simple_form_for [@reservation, @item_reservation] do |f| %>
<%= f.association :room, collection: @room.map{|r| [r.name, r.id]} %>
<%= f.submit "Add" %>
<button type="button" class="btn " data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<%= link_to "Back", client_reservations_path(@reservation.client_id) %>
<% end %>
视图
<h1>ItemReservations#new</h1>
<p>Find me in app/views/item_reservations/new.html.erb</p>
<td><%= link_to "Follow", new_reservation_user_reservation_path(@reservation)%> </td>
<%=render "form", item_reservation: @item_reservation %>
<%= link_to "Back", client_reservations_path(@reservation.client_id) %>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<br/>
<h2>Rooms</h2>
<div class="text-end">
<small><%= @message %></small>
</div>
<br/>
<table id="Room_select" class="table table-striped table-sm">
<head>
发布于 2022-08-16 13:06:53
假设:
-你做了:
-你必须做:
如果这一切都是正确的,那么您有几个选择:
使用这些选项中的任何一个,您本质上将:
RoomsController#modal_show
) (使用AJAX或Turbo (Hotwire))https://stackoverflow.com/questions/73368192
复制相似问题