Marco
Marco

Reputation: 10823

Rails 3.1 Pass Parameter from View to controller

I'm using Rails 3.1 and my view return to controller this parameter (I've checked it on web server log):

"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_record270"=>"1", "bulk_warehouse_serial271"=>"uela2", "bulk_warehouse_asset271"=>"bela2", "enable_record271"=>"1"}

and now I should use this parameter. I know that if I need all warehouse parameter I may do something such as:

@warehouse = Warehouse.new(params[:warehouse])

but if I need a single parameter inside "warehouse" how can I do? Suppose that I want set @serial variable to "bulk_warehouse_serial270" value ("test"); should I do something such as:

@serial = params(:warehouse[:bulk_warehouse_serial270]) 

or instead something such as:

@serial = params(:warehouse)params(:bulk_warehouse_serial270)

Anyone can help me?

Upvotes: 0

Views: 599

Answers (1)

methyl
methyl

Reputation: 3322

That's params[:warehouse][:asset]

Upvotes: 5

Related Questions