How do I make an object a property of a model in Ruby on Rails?
- by iTake
I have this in my schema:
create_table "robots_matches", :force => true do |t|
t.integer "robot_id"
t.integer "match_id"
and I think I want to be able to load a robot and match from within my robots_match model so I can do something like this:
robots_match.find(:id).get_robot().Name
My attempt in the robots_matches model was this:
def get_robot
Robot.find(this.id)
end
I am super new to rails, so feel free to correct my architectural decision here.