Reputation: 21577
i have a model with the following field
when updating the model, i want to set published_at to Time.now when published is set true!
any advice how i can achieve this? thanks!
Upvotes: 0
Views: 110
Reputation: 2084
In your model you need to put this
before_save :set_published_at
def set_published_at
@published_at = Time.now if @published == true
end
Upvotes: 1