On Thu, May 19, 2016, at 19:21, Johnny Stewart wrote:
> I have changed the primary key on a table “statuses” to now be
> entity_id
>
> In my status model I have:
>
> self.primary_key = 'entity_id'
>
> when I try to render a collection of comments associated with a status
> like so:
>
> <%= render @comments %>
>
> I get this error:
>
> PG::UndefinedColumn: ERROR: column comments.status_id does not exist
> LINE 1: SELECT "comments".* FROM "comments" WHERE "comments"."status_id"
>
> I'm assuming when the above call is constructed by rails it is assuming
> the table statuses has primary key
status.id by convention..
>
All it does is taking the model name and suffix it with _id. Specifying
Specify the foreign key used for the association. By default this is
suffixed. So a Person class that makes a has_and_belongs_to_many