Learnings
New Learning
About The App
Hire Me
Writing Samples
Edit Learning
Title
Body
Context: The `new.html.erb` view tried to access `@learning.learned_on` to set the default value for the date field (`value: @learning.learned_on || Date.today`), causing `NoMethodError`. Resolution: I changed the `date_field` value in the view to just `value: Date.today`. The `@learning` instance created by `LearningsController#new` (`Learning.new`) is unsaved and doesn't have attributes populated from database defaults until saved. Learning: I learned to be mindful of when database defaults are applied (on save) versus needing to set defaults explicitly in the controller (`Model.new(attr: default)`) or view (`value: default`) for new object instances presented in forms.
Learned on (YYYY-MM-DD)
Tags
Add comma-separated tags. They help filter learnings later.
Back to Learnings