How to Make :level Change Based on :committed Days?

后端 未结 3 2044
醉话见心
醉话见心 2020-12-22 11:29

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

3条回答
  •  北海茫月
    2020-12-22 11:56

    There are a lot of ways you can do this depending on your business logic. For example if you were unlocking certain privileges with each level you would want to handle it differently than if the level was simply to display a UI feature. Either way you would add a levels table that will hold the name of your level in a :name attribute. Then you would have a habit_level table that would be a join with the foreign key of the habit and the foreign key for the level. When ever you are updating the days you run a check to see if the days are of a certain number, and if they are, you create a record in the join table for the corresponding level and habit.

提交回复
热议问题