帮助在Rails中构建模型

问题描述

|
class Profile
  has_many :projects,:through => \"teamss\"
  has_many :teams,:foreign_key => \"member_id\"
  has_many :own_projects,:class_name => \"Project\",:foreign_key => :profile_id
  has_many :own_teams,:through => :own_projects,:source => :teams
end

class Project
  belongs_to :profile,:class_name => \"Profile\"
  has_many :teams
  has_many :members,:class_name => \"Profile\",:through => \"teams\",:foreign_key => \"member_id\"
end

class Team
  belongs_to :member,:class_name => \'Profile\'
  belongs_to :project
end
我需要创建模型
Evaluation
。我想要做的是在ѭ2member页面中为项目的每个成员(包括所有者)生成一个链接,以使自己成为
Evaluation
。该人将单击链接并评估与该链接相关的人。 “ 4”的所有者将评估所有成员,所有成员将评估所有者。 我将模型
Evaluation
定义如下,但是我想念一些东西:
class Evaluations < ActiveRecord::Base
  belongs_to :evaluated,:class_name => \'Profile\',:foreign_key => \"evaluated_id\"
  belongs_to: :profile,:foreign_key => \"profile_id\"
end
记住
Evaluation
表将具有大量的属性,这就是为什么我不打算使用
has_many_and_belongs_to_many
的原因。 我该如何创建此模型以便执行我想做的事情并能够通过
project#show
页面访问所有我需要的东西? 谢谢! 已编辑 所做的更改:
class Profile
  has_many :evaluations,:dependent => :destroy,:foreign_key => :evaluation_id
  has_many :evaluators,:through => :evaluations,:foreign_key => :profile_id
end

class Project
  has_many :evaluations,:foreign_key => \"project_id\"
end

class Evaluations < ActiveRecord::Base
  belongs_to :evaluated,:foreign_key => \"profile_id\"
  belongs_to: :project,:class_name => \'Project\',:foreign_key => \"project_id\"
end
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)