Forum: Ruby on Rails Defining A model that have two has_many

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2eac5554aeb88694468a955a0db2b274?d=identicon&s=25 Joshua Partogi (Guest)
on 2009-01-18 23:34
(Received via mailing list)
Dear all,

I am currently confused with defining model in Rails that has two
has_many relationship.

I have a model that is called Category, and this model will be used by
two model which is Product and Blog.

Would this definition make sense in rails ?

Category
  has_many :product
  has_many :blog

Product
  belongs_to :category

Blog
  belongs_to :category

Or is there a better way to do it in Rails?

Thanks for the hint.

--
Not by might nor by power, but by His Spirit.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-18 23:40
(Received via mailing list)
On 18 Jan 2009, at 22:33, Joshua Partogi wrote:

>
> Category
>  has_many :product
>  has_many :blog
>
has_many indicates a plural ie it should be has_many :products.
Other than that from a pure rails point of view it makes sense but I
can't tell if what that expresses corresponds to what you want.

Fred
This topic is locked and can not be replied to.