0

I have a question with Rails 3.1 associations. When you have a one-to-many association you put the has_many operators on the many side of the relationship and the usual example does something like this:

class Order < ActiveRecord::Base belongs_to :customer end class Customer < ActiveRecord::Base has_many :orders end 

My question is how should I do this if the class name is Orders? Should I put has_many :orders or should I always name my models using singular nouns?

1 Answer 1

4

Rails convention states that model names should always be singular, so you should never have a model class named Orders; it would probably just be Order.

Sign up to request clarification or add additional context in comments.

3 Comments

and what if i had a model with WorkArea as name?? should i use :work_areas or :workareas
:work_areas is the proper way to snake-case a camel-cased name.
@RenéAlfredoGarcía If my answer answered your question, be sure to click the check mark to the left of it to accept it :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.