Reputation: 71
Which is the best way to have a draft version of a model? I have a Course model with his description and lesson models.
class Course < ApplicationRecord
has_many :lessons
has_one :description
...
end
class Description < ApplicationRecord
belongs_to :course
...
end
class Lesson < ApplicationRecord
belongs_to :course
...
end
The description and lesson model have a state machine with a "published" status, that when they have it, their information will be published. I need the draft version to modify their information without change the published information. How can I do this?
PD: I have tried to use the draftsman gem, but doesn't work with Rails 5.
Upvotes: 4
Views: 1115
Reputation: 2727
You could try draftpunk or use their approach to implement your custom solution.
https://github.com/stevehodges/draftpunk
Idea is to create store a draft version in the same database table. Just with an id referer. In your application you have to take care:
I am interested how you end up
Upvotes: 2