default_value_for
default_value_for copied to clipboard
Provides a way to specify default values for ActiveRecord models
This adds support for the recently released [Rails 7.0](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision).
ActiveModel validations usually have `:allow_nil` keyword option. Ruby method naming also follow this theme: https://bugs.ruby-lang.org/issues/17391
Here's a screenshot of the readme:  Here are additional alternative gems I found: https://github.com/fnando/defaults https://github.com/makandra/has_defaults I'm leaning towards using default_value_for over these alternatives because it has more GitHub stars...
When a new database record has a column that is set to its database default value, the `"#{attribute}_changed?"` method returns false, which causes the `connection_default_value_defined` value to be true and...
This should fix Issue #84 The object initialize() method can only take a single option, usually a hash of attribute names/values. When default_value_for is used in a subclass all the...
If using ```default_value_for``` within a subclass of another model, then the class instance initialization will fail with: **```ArgumentError (wrong number of arguments (given 2, expected 0..1))```** This is version **3.3.0**...
https://github.com/FooBarWidget/default_value_for/blob/c52d291c0070c72896926c6dd9df9c6b90e81147/lib/default_value_for.rb#L159-L170 The above code has a few more edge cases that are missed, specifically with the second two cases in the outer conditional where the attribute is not backed by...
It's recommended in the README that we use `alias_method_chain`, but its been deprecated in Rails 5. This should be changed. See https://github.com/rails/rails/pull/19434