rails 3, объединение еще трех таблиц

Я хотел бы объединить еще три таблицы в rails 3

, мой код

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

schema

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).

Не могли бы вы мне помочь? спасибо и извините за мое английское выражение, я француз.

6
задан user488464 27 October 2010 в 12:07
поделиться