Ruby on Rails Friday, July 6, 2012

Hello there,


I'm a beginner in Rails, so forgive me if this question is too dumb ;p
Does Rails provide any helper/linecode to create a foreign key in the database (via migration)?

When I use, for example, belogs_to :class, :foreign_key => id_class, I'm just setting the name
of the foreign key.

In the same way, when I use t.reference :class in the migration, I'm just creating an column class_id 
with the appropriate class in the database... but I don't properly create the foreign key in database-level, 
right?

So, is there a nice way to do that in Rails? I already saw some solutions in the web, but I couldn't find
any convention. Which would be the best way to do that?

Thanks in advance (:

P.S: sorry if the English is not good ;p

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/S7TEeBThUQYJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.

No comments:

Post a Comment