i want to activate a post in typical date(which is scheduled by user) and update data in model
for example.
Post schema
t.string :title
t.text :body
t.datetime :valid_from
t.datetime :valid_until
t.string :act_status, default: "padding #["pending", "activate", "expired"]
every post has valid_from, valid_until, and act_status
act_status has 3 phase (pending, activate, and expired)
user fill out all infos,
and when "Time.now" meets "valid_from", post will be valid to all user and it's "act_status" will change into "activate" (@post.act_status = "activate")
when "Time.now" meets "valid_until", post will invalid to other users and "act_status" will change into "expired"(@post.act_status = "expired")
my question is, how rails changes value automatically in typical date.
in my thought, i can change value when "user" acts something(fires some action such as CRUD)
but in my case, user just saves value and rails should fire that action.
i dont have any idea to solve it.
if you have some instructions or guide, please let me know
thanks..
additionally is it efficient way to store options of "act_status" in models?
Post.rb
validates :act_status, inclusion: { in: %w(padding activate finish) }