Thanks. So when i add a participant i pass in the param[:trip_id] to the 
create controller?

On Wednesday, January 2, 2013 1:15:34 PM UTC-8, Chris Radcliff wrote:
>
> Hillary Hueter <[email protected] <javascript:>> wrote:
>
>> Also is there a way when they add the participant to  assign the 
>> participant to that trip by default. I was thinking of using a hidden 
>> field, but there's probably a better way to do it.
>
>  
> A hidden field works fine, but you might also put the trip ID into the 
> path. For example, if the path to the trip with ID 123 is /trips/123, the 
> path to POST a new participant could be /trips/123/participants.
>
> In Rails, if you use resources in your routing, you can nest the 
> participants resources under the trips like so:
> resources :trips do
>   resources :participants
> end
>
> You could also match the route directly:
> match "trips/:trip_id/participants" => "participants#create", :via => :post
>
> Either way gets you the path I mentioned above, and params[:trip_id] will 
> contain the ID you want.
>
> ~chris
>
>
>  
>

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to