모델 방법에 자식 방법를 호출 할 수 없습니다 : student.rb에서나는이와 진정한 투쟁 데
:
def subject_avg
self.goals.each do |goal|
goal.subject_id
end
end
것은이 아무것도 '할'하지 않습니다 - 내가 말을해야 또는 그것은
def subject_avg
self.goals.each do |goal|
goal.id
end
end
또는
def subject_avg
self.goals.each do |goal|
goal.goal
end
end
에서 다른 아무것도하지 않습니다
상관없이, 피사체에 속하는 목표의 배열을 반환 무엇 : 그래서 그냥 통과되었다 처음
[
#<Goal id: 28, goal: "Do it on command", subject_id: 10, created_at: "2013-08-25 10:59:35", updated_at: "2013-08-25 10:59:35", default: nil>,
#<Goal id: 29, goal: "Make it chunky", subject_id: 10, created_at: "2013-08-25 10:59:35", updated_at: "2013-08-25 10:59:35", default: nil>,
#<Goal id: 30, goal: "Hit the mark", subject_id: 10, created_at: "2013-08-25 10:59:35", updated_at: "2013-08-25 10:59:35", default: nil>,
#<Goal id: 31, goal: "Puke and rally", subject_id: 10, created_at: "2013-08-25 10:59:35", updated_at: "2013-08-25 10:59:35", default: nil>
]
나는 그냥 어떤 이유로 각 블록을 읽을 수 없습니다/읽기되지 않은 생각을 self.goals.each
의 결과 (비록 그것이 일어나고있는 것처럼 보이지만). 내가 존재하지 않는 메소드를 호출 할 경우,이 오류가 발생합니다 : 내가보기에 같은 각 블록을 넣어 경우 예상대로
undefined method `FFS_do_something!' for #<Goal:0x000001064329f0>
이 작동
def subject_avg
self.goals.each do |goal|
goal.FFS_do_something!
end
end
수익을 (내가 호출 할 수 있습니다 각 블록 내에서 '목표'에 대한 메소드)