[Locomotive-users] Problem with :belongs_to relation

Samuel Linde samuel.linde at gmail.com
Mon Feb 26 16:47:24 GMT 2007


Hi Steve!

Thanks for your reply. I'll try to give you more info about it.

The schema looks like this:

create_table "customers", :force => true do |t|
   t.column "kind",         :string
   t.column "company_name", :string
   t.column "first_name",   :string

...

end

create_table "bookings", :force => true do |t|
   t.column "customer_id", :integer
   t.column "kind",        :string
   t.column "status",      :string

...

end

And my classes:

booking.rb

class Booking < ActiveRecord::Base

   belongs_to :customer
   has_many :booking_events

...

end

customer.rb

class Customer < ActiveRecord::Base
   has_many :customer_phones
   has_many :customer_events
   has_many :bookings
end


Pretty basic things, which makes me quite puzzled about what's going  
on. :-)

Thanks for taking your time!

/Samuel


26 feb 2007 kl. 17.29 skrev Stephen Waits:

>
> On Feb 26, 2007, at 7:37 AM, Samuel Linde wrote:
>
>> I've set up two models, Customer and Booking, with a has_many -  
>> belongs_to relationship.
>> I have a list view for my BookingsController which shows the  
>> customer's name for each booking record,
>> via booking.customer.name.
>
> Hi Samuel,
>
> I'm certain we can help.  Can you please explain your schema and  
> the Customer/Booking relationship in a little bit more detail?
>
> Thanks,
> Steve
> _______________________________________________
> Locomotive-users mailing list
> Locomotive-users at lists.raaum.org
> http://lists.raaum.org/mailman/listinfo/locomotive-users



More information about the Locomotive-users mailing list