1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
Sean Griffin ba06dab545 Memoize user provided defaults before type casting
When a proc is given as a default value, the form builder ends up
displaying `Proc#to_s` when the default is used. That's because we
didn't handle the proc until type casting. This issue technically can
occur any time that a proc is the value before type casting, but in
reality the only place that will occur is when a proc default is
provided through the attributes API, so the best place to handle this
edge case is there.

I've opted to memoize instead of just moving the `Proc#call` up, as this
made me realize that it could potentially interact very poorly with
dirty checking.

The code here is a little redundant, but I don't want to rely on how
`value_before_type_cast` is implemented in the super class, even if it's
just an `attr_reader`.

Fixes #24249

Close #24306
2016-03-24 14:58:23 -06:00
..
active_record/connection_adapters introduce conn.data_source_exists? and conn.data_sources. 2015-09-22 19:48:44 +02:00
assets
cases Memoize user provided defaults before type casting 2016-03-24 14:58:23 -06:00
fixtures Fixed where for polymorphic associations when passed an array containing different types. 2016-02-16 10:41:26 -08:00
migrations Internal test migrations use the private 'Current' version 2015-12-15 17:18:09 +10:30
models Fix warning: method redefined; discarding old female 2016-03-12 17:06:43 +09:00
schema Merge pull request #23797 from kamipo/case_sensitive_comparison_for_non_string_column 2016-03-11 19:10:29 -03:00
support Deprecate #table_exists?, #tables and passing arguments to #talbes 2015-11-09 23:13:23 +09:00
.gitignore
config.example.yml Remove legacy mysql adapter 2015-12-17 15:54:57 +00:00
config.rb