aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/actions.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-11-27 14:06:51 -0700
committerSean Griffin <sean@seantheprogrammer.com>2017-11-27 14:06:51 -0700
commit95b86e57a6c07bc636f8feab4afd4c7fe0ca512c (patch)
treec665e7cd5c61f2c6cd2dae0374838e8c144c98b5 /railties/lib/rails/generators/actions.rb
parent924a368f5c654f5304e575c767eb0fc64adc8659 (diff)
downloadrails-95b86e57a6c07bc636f8feab4afd4c7fe0ca512c.tar.gz
rails-95b86e57a6c07bc636f8feab4afd4c7fe0ca512c.tar.bz2
rails-95b86e57a6c07bc636f8feab4afd4c7fe0ca512c.zip
Change how `AttributeSet::Builder` receives its defaults
There are two concerns which are both being combined into one here, but both have the same goal. There are certain attributes which we want to always consider initialized. Previously, they were handled separately. The primary key (which is assumed to be backed by a database column) needs to be initialized, because there is a ton of code in Active Record that assumes `foo.id` will never raise. Additionally, we want attributes which aren't backed by a database column to always be initialized, since we would never receive a database value for them. Ultimately these two concerns can be combined into one. The old implementation hid a lot of inherent complexity, and is hard to optimize from the outside. We can simplify things significantly by just passing in a hash. This has slightly different semantics from the old behavior, in that `Foo.select(:bar).first.id` will return the default value for the primary key, rather than `nil` unconditionally -- however, the default value is always `nil` in practice.
Diffstat (limited to 'railties/lib/rails/generators/actions.rb')
0 files changed, 0 insertions, 0 deletions