I'm attempting to use the Super Inplace Controls plugin, which has an in_place_select method. I have the following models:
class Incident < ActiveRecord::Base
belongs_to :incident_status
validates_existence_of :incident_status
end
class IncidentStatus < ActiveRecord::Base
has_many :incidents
end
Right now, IncidentStatus is just an ID and a name ('Open' and 'Closed'). In the show view for Incident, I want to allow a user to click on the current status, and change it using a select menu. So in show.html.erb, I have the following:
<p>
<b>Status:</b>
<%= in_place_select :incident, :incident_status_id, :choices => @statuses.map { |e| [e.name, e.id] }, :display_text => @status.name %>
</p>
This follows the example given in the Super Inplace Controls documentation pretty closely, which is:
<%= in_place_select :employee, :manager_id, :choices => Manager.find_all.map { |e| [e.name, e.id] } %>
This actually works fine until I click okay to change the field and submit the POST. I see the Status, then when I click on it brings up a drop down menu with 'Open' and 'Closed'. When I select 'Closed' and press okay, the form disappears. The following shows up in the web server console:
Processing IncidentsController#set_incident_incident_status_id (for 127.0.0.1 at 2010-05-14 10:18:43) [POST]
Parameters: {"commit"=>"OK", "action"=>"set_incident_incident_status_id", "authenticity_token"=>"eahXrzwJwe+h2Byi1ELWXLy0QNmqF2EEXNw+eAfUJwU=", "id"=>"1", "controller"=>"incidents", "incident"=>{"incident_status_id"=>"1"}}
...snip...
ActionController::UnknownAction (No action responded to set_incident_incident_status_id. Actions: admin?, authenticated?, authorized?, create, destroy, edit, index, new, set_incident_incident_status, set_incident_title, show, and update):
So it appears to be looking for a method "set_incident_incident_status_id". If I define this method in my Incident Controller, it seems to be okay, but I have no idea how to grab the "incident_status_id"=>"1" that was passed in and set it as the foreign key.
Any ideas? Thanks in advance!