tbrooke
tbrooke

Reputation: 2197

Rails parameters

I am trying to create a join between two objects and I am confused about pasing parameters. I have a form that submits this:

 assign_service_url([abs_id: abstractor.id, serv_id: service.id]),

I would think that the following would work but it doesn't

 @abstractor = Abstractor.find(params[:abs_id]) 
 @service = Service.find(params[:serv_id])

Here is what I get in my console:

params[:id]
=> "abs_id=2&serv_id=1"
>> params[:abs_id]
=> nil
>> params[:abs]
=> nil
>> params[:id]
=> "abs_id=2&serv_id=1"
>> params
=> {"_method"=>"put", "authenticity_token"=>"WwSfk8rw8PfWA8FNLZs+6SUZBEgCW7ZHF2BuPxLxzsXfwRQWmfr7tfDBH/nBCytuYs6GjDdBOeGzVeb9Ph399A==",
"controller"=>"services", "action"=>"assign", "id"=>"abs_id=2&serv_id=1"}

I could parse the string but it seems that it should be much easier. I think I am missing something

How do I make this work?

Upvotes: 0

Views: 34

Answers (1)

Sharvy Ahmed
Sharvy Ahmed

Reputation: 7405

Pass Hash instead of an array, like this:

assign_service_url({abs_id: abstractor.id, serv_id: service.id})

Now you will be able to receive params[:abs_id] & params[:serv_id]

Upvotes: 1

Related Questions