Ruby/Rails - Models Named with Two Words (Naming Convention Issues)
Your class should be singlular.
Name it PromotedEvent
in the file promoted_event.rb
a = PromotedEvent.new
Model names are singular and camel case like so pe = PromotedEvent.new()
the file should be promoted_event.rb
Controllers are plural
PromotedEventsController
constants are ALL_CAPS
locals are separated_by_underscores_and_lowercase
table names are plural 'SELECT * FROM promoted_events`
If it helps, I always think of it like this:
The model name is singular because it represents a single, specific thing. So, PromotedEvent
is a specific promoted event that has a name, date, etc.
The table name on the other hand is plural. This is because the table stores a collection of these singular items. So, promoted_events.
In rails, filenames are mostly a matter of convention since ruby has pretty lax rules in this regard, but generally it's class_name.rb
. This page might help you get a better overview of what conventions are used where and what is specific to Ruby versus Rails.