PDA

View Full Version : has_many relationships - use variable of calling class?


rubyonrails-talk
August 28th, 2006, 08:55 AM
Hi all,
I'm having trouble issuing what I consider to be a simple one to many
relationship in rails. Here's some code:
def SoccerPlayer < ActiveRecord::Base
has_many :goal_list, :class_name => 'Goal', :foreign_key =>
'player_id', :conditions => 'player_name = #{last_name}'
end
Basically, I want goal_list to be a list of all goals scored by this

More... (http://groups.google.com/group/rubyonrails-talk/msg/84725b4d4b15d651)