bdx
bdx

Reputation: 3516

Rails - Basic model conventions and basic association confusion

My understanding of the conventions I'm currently dealing with is as follows:

Model names should be in TitleCaps.

Variable names should be lower_cased_and_under_scored.

Associations should be to the singular version of the foreign table name with _id appended, e.g. user_uploaded_picture_id

Upvotes: 1

Views: 77

Answers (1)

KARASZI István
KARASZI István

Reputation: 31467

Multiple questions in one :)

  1. Both model_name and ModelName are accepted and generates the correct model and table names.
  2. You don't need to specify every associations only those which you want to use.
  3. No, you don't need to create a model for every table. But if you'll use that table from Rails it's easier to have one.

Upvotes: 1

Related Questions