I would like to join more than three tables in rails 3
my code
class offer <ActiveRecord :: Base
belongs_to: user
has_many: usercomments,: dependent =>: destroy
has_many: comments,: through =>: usercomments,: dependent =>: destroy
end
class User <ActiveRecord :: Base
has_many: usercomments,: dependent =>: destroy
has_many: comments,: through =>: usercomments,: dependent =>: destroy
has_many: offers,: dependent =>: destroy
end
class Usercomment <ActiveRecord :: Base
belongs_to: user
belongs_to: comment
belongs_to: offer
end
class Comment <ActiveRecord :: Base
has_one: usercomment,: dependent =>: destroy
has_one: offer,: through =>: usercomments
has_one: user,: through =>: usercomments
end
scheme
create_table "offers", :force => true do |t|
t.integer "step_id"
t.integer "user_id"
t.date "offerdate"
end
create_table "users", :force => true do |t|
t.string "firstname", :limit => 100, :default => ""
t.string "lastname", :limit => 100, :default => ""
t.string "email", :limit => 100
end
create_table "usercomments", :force => true do |t|
t.integer "user_id"
t.integer "airoffer_id"
t.integer "comment_id"
t.boolean "shared"
end
create_table "comments", :force => true do |t|
t.string "comment"
t.datetime "created_at"
t.datetime "updated_at"
end
index.html.erb
<% airoffers.each do |airoffer| %>
???
<% end %>
html.erb (offer_id) (user_id).
? , .