[Feature] `accepts_nested_attributes_for` with primary key alternative

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Feature] `accepts_nested_attributes_for` with primary key alternative

Nick Rivadeneira
In our public API, we use a UUID for record identifiers, however our primary key internally is the default incrementing integer in Postgres. I'd like to submit a PR that adds an option to `accepts_nested_attributes_for` that would change which key is being queried on, but doesn't require a change of `primary_key` in the model.

Would this get accepted? If so, I'm interested in opinions on a good name for the option. Could be as simple as `:primary_key`, similar to how `belongs_to` has an option for `:primary_key` which does not require a primary key change in the associated model.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/ecc0ce4d-cf39-44cc-8c56-67ec27980b13%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature] `accepts_nested_attributes_for` with primary key alternative

Kevin Gnadinger
I support this and am surprised it isn't already implemented. Public-facing ID's and internal PKs is a pretty common architecture. 

On Mon, Aug 5, 2019 at 9:36 AM Nick Rivadeneira <[hidden email]> wrote:
In our public API, we use a UUID for record identifiers, however our primary key internally is the default incrementing integer in Postgres. I'd like to submit a PR that adds an option to `accepts_nested_attributes_for` that would change which key is being queried on, but doesn't require a change of `primary_key` in the model.

Would this get accepted? If so, I'm interested in opinions on a good name for the option. Could be as simple as `:primary_key`, similar to how `belongs_to` has an option for `:primary_key` which does not require a primary key change in the associated model.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/ecc0ce4d-cf39-44cc-8c56-67ec27980b13%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAFDQ6N2y_oj-v%2BeRBss6BH0%3Dgh61SOJbNj8DoJjO9jdwUrkQSw%40mail.gmail.com.