Explicitly Set Table Name
ActiveRecord includes a
table_name method that infers your database table name based on a class name. For an empty model called
AlternativePost, here's what it comes up with:
 > AlternativePost.table_name => "alternative_posts"
If this isn't right, you're in trouble (Postgres example):
 > AlternativePost.new PG::UndefinedTable: ERROR: relation "alternative_posts" does not exist
Luckily, you can set the table name explicitly with the
class AlternativePost < ActiveRecord::Base self.table_name = 'posts' end
Now Rails knows which database table to refer to:
 > AlternativePost.table_name => "posts"  > AlternativePost.new => #<AlternativePost:0x007f8554dcbd98 id: nil, title: nil...
A practical application would be a model
Post that corresponds to a table organized inside a Postgres schema