Accessing a nested hash in a controller

Posted by Magicked on Stack Overflow See other posts from Stack Overflow or by Magicked
Published on 2010-05-14T15:30:50Z Indexed on 2010/05/14 15:34 UTC
Read the original article Hit count: 178

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby