Closed cognitiveflux closed 9 years ago
It's supposed to work as you say: The default or Proc are only applied if no value is present. Would you be able to create a branch with a breaking spec so I can clone it and take a look? Or would you rather just fix it. The behavior is (was) just as Rails. Defaults only override missing values.
Unless you need it done right away, I'll create the spec and provide a fix.
That would be perfect. Thanks!
Just submitted #125, seems to solve it.
how often do you typically publish new gems?
I’m overdue.
-- Steve Ross
On November 6, 2014 at 9:01:27 AM, cognitiveflux (notifications@github.com) wrote:
how often do you typically publish new gems?
— Reply to this email directly or view it on GitHub.
I'm not sure if this is the intended behavior, but if a default value is provided to a model and that column has an attribute assigned using the
create
method, the supplied value is not applied; instead, the default value is applied.I was thinking that the
default
value is applied if and only if there is no value for that column on creation, not instead of any values upon creation.I was going to trying using a
Proc
, but looking at the call that applies the value here, it looks like the value is not passed to theProc
either.For example:
Perhaps this method should be like the following?
Or since I'm not sure how that would impact the
Proc
default value, changing this line to:Easy to create a pull request, just not sure what the intended behavior is when this was originally designed.