I’m making a blog app. My Post model has_many :revisions (one revision for each edit you make).
My Post model accepts_nested_attributes_for :revisions
What’s the best way to prevent the user from editing ALL the revisions of some post (which they can do by hacking the form)?
= simple_form_for @post do |f|
= f.error_notification
= f.simple_fields_for :revisions, @revision do |r|
= r.input :title
= r.input :body
You can pass an option to accepts_nested_attributes_for called :reject_if, like this:
Within the proc passed in the option, you can specify additional criteria on which revisions are eligible to be edited.