シナリオは、u ユーザー has_many head_bookings と head_bookings has_many の予約があり、アパートメントが予約に属しているというものです。head_booking には注文番号があります。したがって、ユーザーがログインすると、head_booking (注文番号) によってアパートメント グループの予約が取得されます。
は私のモデルです
class User < ActiveRecord::Base
has_many :head_bookings
end
class HeadBooking < ActiveRecord::Base
has_many :bookings
belongs_to :user
# attr_accessible :title, :body
end
class Booking < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :appartment
belongs_to :head_booking
accepts_nested_attributes_for :head_booking
end
テーブルにダミーデータを作成し、コンソールでこれを試しました:
u = User.find(1)
u.head_bookings
u.head_bookings.bookings
コマンド u.head_bookings.bookings を使用すると、「undefined method `bookings'」というエラーが表示されます
私は何を間違っていますか?? ありがとう..レムコ