We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey, I'm trying to configure default values for attributes but I'm not sure if I'm doing something wrong or it's something not supported/bug.
Defining "default" will return the default value only when instantiating the store model, but not when retrieving an attribute
here's a simplified example that shows the behavior.
class Settings < ApplicationRecord attribute :colors, Colors.to_type validates :colors, store_model: true, allow_blank: true end class Settings::Colors include StoreModel::Model attribute :bg_default, :string, default: "#ff0000" attribute :bg_overlay, :string, default: "#a6af1d" end irb(main):040:0> Settings.last.colors => #<Settings::Colors bg_default: nil, bg_overlay: nil, irb(main):041:0> Settings.new.colors => #<Settings::Colors bg_default: #ff0000, bg_overlay: #a6af1d, irb(main):042:0> Settings.new.colors.bg_default => "#ff0000" irb(main):043:0> Settings.last.colors.bg_default => nil
The text was updated successfully, but these errors were encountered:
Hi @raivil! This is how attributes API works, you have to add the default to the database to make it work
Sorry, something went wrong.
No branches or pull requests
Hey,
I'm trying to configure default values for attributes but I'm not sure if I'm doing something wrong or it's something not supported/bug.
Defining "default" will return the default value only when instantiating the store model, but not when retrieving an attribute
here's a simplified example that shows the behavior.
The text was updated successfully, but these errors were encountered: