Ruby on Rails Thursday, May 19, 2016

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..

so – is it no longer possible to use the render functionality as above?
Or have I missed something which I need to make this work?

How can I get rails to use entity_id instead of the now changed
status_id?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5609fa6369075c7b776a25d29422a6a6%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment