How do I make an object a property of a model in Ruby on Rails?

Posted by iTake on Stack Overflow See other posts from Stack Overflow or by iTake
Published on 2012-03-24T14:12:31Z Indexed on 2012/03/25 5:29 UTC
Read the original article Hit count: 134

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about object

Related posts about model