【发布时间】:2012-06-19 16:48:10
【问题描述】:
我正在设置一个提醒服务,通过电子邮件发送与个人兴趣和城市相关的交易。基本上,用户输入重要日期(朋友生日、周年纪念日等)和那个特别的人的兴趣。
我想根据 1)用户所在城市和 2)相关人员的兴趣向他们发送交易
我应该如何为 Deal 模型设置关联?
到目前为止我有什么..
class User < ActiveRecord::Base
belongs_to :city
has_many :person_interests, :as => :person
has_many :interests, :through => :person_interests
end
class City < ActiveRecord::Base
attr_accessible :name
belongs_to :province
has_many :users
end
class PersonInterest < ActiveRecord::Base
belongs_to :interest
belongs_to :person, :polymorphic => true
end
class Interest < ActiveRecord::Base
has_many :person_interests
end
谢谢!
【问题讨论】:
-
到目前为止你有什么?什么不起作用或对您来说似乎不理想?
-
@rfunduk 添加了我已有的内容。一切都很好,收集我需要的信息也很好。只是想知道如何将新交易模型与兴趣和城市联系起来。
-
交易会是兴趣和城市的belongs_to吗?
标签: ruby-on-rails ruby-on-rails-3 associations