我有两个视图,第一个是显示所有授权的表,我是如何通过仅检查其他视图的授权?
这是第一个观点:(一切都好)
(...)
<% @authorizations.each do |authorization| %>
<tr>
<td><%= check_box_tag 'authorization_marked' %></td>
(...)
<%= f.button :submit, "To Reserve" %>
我的第一个和第二个控制器:
def index
if params[:search_employee_by_cpf].present?
@employees = Employee.search_cpf(params[:search_employee_by_cpf]).all
@authorizations = Authorization.search_employee_by_cpf(params[:search_employee_by_cpf]).all
else
@authorizations = []
end
end
# GET /refinancings/new
def new
@employee = Employee.search_cpf(params[:search_employee_by_cpf])
@authorizations.authorization_marked = true # PROBLEM HERE
@refinancing = Refinancing.new
end
在其他视图中,我只想显示已选中的内容:
<h3>Reserved value</h3>
<table class="table table-condensed table-bordered table-striped">
<thead>
<th>Contract number</th>
<th>Parcel value X Quantity of Parcels</th>
</thead>
<% @authorizations.each do |authorization| %>
<tbody>
<tr>
<td><%= authorization.contract_number %></td>
<td><%= number_to_currency authorization.parcel_value %> x <%= authorization.qtd_parcel %></td>
</tr>
</tbody>
<% end %>
</table>