2016-04-11 42 views
0

我有兩個視圖,第一個是顯示所有授權的表,我如何通過只檢查授權檢查其他視圖?只通過複選框檢查其他視圖

這是第一個觀點:(都可以在這裏)

(...) 
<% @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> 
+0

這部分:'我怎麼做的傳球只檢查了其他觀點的授權',我不明白,在所有。 –

+0

需要更多的上下文。你可以顯示第一個視圖的整個表單部分嗎?還有控制器在您的第三代碼塊中渲染HTML的行爲? –

+0

是的,我會更新 –

回答

1

因此,您的第一個表單需要捕獲要傳遞到第二個視圖的所有行的ID號。在第二個操作中,您需要捕獲這些參數,並創建要加載第二個視圖的對象的集合。

仔細看看發佈第一個表單時傳遞了什麼數據,這就是您必須使用的數據來創建所需的下一個集合。

+0

在另一個地方有git ot的例子嗎?我嘗試了,但還沒有,我在我的git上做了一個例子:github.com/eltonsantos/playing_checkboxes –

+0

我也試過使用.pluck(:id)但不工作=( –

+0

<%= check_box_tag'authorization_ids [ ]',authorization.id%>這是我的複選框,沒關係? –

相關問題