Tuesday, September 18, 2012

[Rails] Re: Re: "belongs_to" aliases

Panayotis Matsinopoulos wrote in post #1076115:
> You may be right, but I have found a lot of other posts on Internet that
> they complain about "belongs_to". It does not bear the correct meaning
> for
> all cases. For example:
>
> class Product
>
> belongs_to :status
>
> end
>
> .....Awful. No, the Product does not "belong" to a Status. It "has_a"
> status.

The "belongs to" is not really intended to mean what you seem to think
it means. The way I think about it is that the product "object" belongs
to the status "object".

I agree with Frederick. I see no reason to muddy the waters and
potentially confuse experience Rails developers.

Consistency in naming is far more important than grammar syntax in an
API. Besides that, has_many, belongs_to, etc. are internal
implementation details. Not need to worry to much about the public API
that the are used internally to create:

product.status

It makes little difference what the internal implementation of Product
looks like from the outside.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
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 https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate