0
我創建一個Rails 3.1的應用程序,我已經下大問題:我必須檢索從視圖中的某些參數控制器檢索複雜的參數從視圖中的Rails 3.1
這是我的看法:
<tr class="<%= cycle("odd", "even") %>">
<td><%= text_field_tag("bulk_warehouse_serial#{@count}_page#{params[:page]}", bulk_warehouse.serial, :disabled => true) %></td>
<td><%= text_field_tag("bulk_warehouse_asset#{@count}_page#{params[:page]}", bulk_warehouse.asset, :disabled => true)%></td>
<td><%= check_box_tag "enable_record#{@count}_page#{params[:page]}",1,false,{:onclick => "bulk_warehouse_serial#{@count}.disabled =
bulk_warehouse_asset#{@count}.disabled =
!this.checked;"}%></td>
<td class="last">
<%= link_to "#{t("web-app-theme.delete", :default => "Delete")}", bulk_warehouse_path(bulk_warehouse), :method => :delete, :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
</td>
</tr>
</div>
<% @count = @count +1 %>
在我控制我有一些諸如:
...
@count = 0
...
,這是由Web服務器日誌生成的內容:
"warehouse"=>{"asset"=>"turiturira", "serial"=>"caricarira", "project_id"=>"1", "hardware"=>{"brand_id"=>"21"}, "hardware_id"=>"60", "state_id"=>"4", "position_id"=>"1", "logicalwarehouse_id"=>"3", "extra_id"=>"3"}, "bulk_warehouse_serial270"=>"t", "bulk_warehouse_asset270"=>"test", "enable_record2_page0"=>"1", "bulk_warehouse_serial2"=>"uela2", "bulk_warehouse_asset2"=>"bela2", "enable_record3_page0"=>"1"}_
e 現在,在我的控制器中,我需要一個首先檢查所有「enable_record#{@ count} _page#{params [:page]}」值的操作,然後執行一些操作。我如何在控制器中聲明?我在想,如:
@count=0
@page = params[:page]
@count_max = 10
until @count == @count_max
if params[:warehouse][:enable_record#{@count}_page#{params[:page]}] == 1
...doing something...
end
@[email protected]+1
end
但它給了我一個驚喜;有什麼建議麼?
你得到的錯誤是什麼? – miked 2012-03-22 14:42:56