This is really a question about naming conventions.
I have a model called PromotedEvents
The file is called promoted_events.rb
I created the table wi
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.
Your class should be singlular.
Name it PromotedEvent
in the file promoted_event.rb
a = PromotedEvent.new
If you are an extreme rails n00b like me, then you will want to remember to create a class definition for your newly created table and place it in app/models.
It would go like
class LargeCat < ActiveRecord::Base
belongs_to :zoo
end
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`