The default value for a field in a change set

I have a model and change method. I want to have an optional field in which I want to set a default value if it is not passed to chargeet. How can i do this?

+4
source share
1 answer

When you create your circuit, you can give it a default value by passing it an atom :default.

schema "foo" do
  field :name, :string, default: "bar"
end
+8
source

Source: https://habr.com/ru/post/1662230/


All Articles