Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 计算嵌套属性rails 2上的父级_Ruby On Rails - Fatal编程技术网

Ruby on rails 计算嵌套属性rails 2上的父级

Ruby on rails 计算嵌套属性rails 2上的父级,ruby-on-rails,Ruby On Rails,我的注册。rb attr_accessible :semester_id has_many :studentpayments has_many :student_deductions belongs_to :enrollment belongs_to :enrollment 我的studentpayment.rb attr_accessible :semester_id has_many :studentpayments has_many :student_deductions belo

我的
注册。rb

attr_accessible :semester_id
has_many :studentpayments
has_many :student_deductions
belongs_to :enrollment
belongs_to :enrollment
我的
studentpayment.rb

attr_accessible :semester_id
has_many :studentpayments
has_many :student_deductions
belongs_to :enrollment
belongs_to :enrollment
我的
student\u扣减.rb

attr_accessible :semester_id
has_many :studentpayments
has_many :student_deductions
belongs_to :enrollment
belongs_to :enrollment
如何根据
学期id
获取唯一的注册,以及
注册是否有
学生付款
学生扣减

@enrollment = Enrollment.find_by_semester_id(id) # find by semester_id

@enrollment.studentpayments.any? # if @enrollment has any student payments
@enrollment.student_deductions.any?