Map.resources and link confusion

I have:

class Booking < ActiveRecord::Base
belongs_to :guest

class Guest < ActiveRecord::Base
has_many :bookings

map.resources :guests, :has_many => [:bookings]


before_filter :load_user

def load_user
@guest = Guest.find(params[:guest_id])

So I can do something like:

…works fine.

But now

does not work any longer!

ActiveRecord::RecordNotFound in BookingsController#index
Couldn’t find Guest without an ID

What am I missing?


That’s because u have defined nested routes and it will not handle
that URL. It needs the parent id. Do rake routes to get the list of
URL helper methods. U need to define route that will handle it.

Sent from my iPhone

On Dec 19, 2007, at 2:02 PM, Jochen K. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs