views:

31

answers:

1

I have the following (snipped) parameters passed into my controller.

Parameters: {"commit"=>"OK", "action"=>"set_incident_incident_status_id", "id"=>"1", "controller"=>"incidents", "incident"=>{"incident_status_id"=>"1"}}

I know that if I want to select the incident, I can do:

@incident = Incident.find(params[:id])

How do I access the "incident"=>{"incident_status_id"=>"1"}?

I thought to try something like:

@incident_status = IncidentStatus.find(params[:incident => :incident_status_id])

But that didn't work. I'm assuming it's just a syntax problem at this point, and I haven't found a solution yet. Any help would be much appreciated!

+1  A: 

Small tweak:

@incident_status = IncidentStatus.find(params[:incident][:incident_status_id])
fig
Hmmm, I'm getting the following error: NoMethodError (undefined method `[]' for :incident:Symbol):
Magicked
Fixed, try that instead
fig
That was it. Thanks!
Magicked