First of all, the question is very confusing as to the plurality of outcome
vs outcomes
. If a Meeting has_one Outcome then you you would use the singular form when referring to the reference. Basically, given has_one :outcome
, ":outcome" is the method name to be used. So you'd say meeting.outcome
instead of meeting.outcomes
. And the build method for has_one would be like meeting.build_outcome
instead of meeting.outcomes.build
. The latter is the api for a has_many relationship.
With that out of the way, if you want to get the current Meeting from the Outcomes controller, the best way to do this is with nested resources. So in the routes file you'd have, e.g.:
resources :meetings do
resources :outcomes
end
After you do that, run rake routes
to see the routes available to you. In there you'll see an expected url format of POST /meetings/:id/outcomes
which you would use here. So in this case, the create
method would get the Meeting object from params[:id]
, from which the outcome relationship can be created.