I\'m creating a habit tracking app.
When a User creates a habit he will put in its :date_started
and which days he is :committed
to doing t
What exactly is committed
? I see:
t.text :committed
and
committed.map { |day| Date::DAYNAMES.index(day) }
That doesn't really make sense, I'm not sure how that works for you. It looks like you're storing multiple day names, if that's the case you should use an array of some sort (either strings or integers). Then you can set n_days
to simply committed.length
.
I would change that column to t.string :committed, array: true, default: []
or t.integer :committed, array: true, default: []
.