Rename the following post replacement attributes: * file_size_was -> old_file_size * file_ext_was -> old_file_ext * image_width_was -> old_image_width * image_height_was -> old_image_height * md5_was -> old_md5 In Rails 6.1, having attributes named `file_size` and `file_size_was` on the same model breaks things because it conflicts with Rails' dirty attribute tracking.
20 lines
477 B
Ruby
20 lines
477 B
Ruby
class PostReplacementPolicy < ApplicationPolicy
|
|
def create?
|
|
user.is_moderator?
|
|
end
|
|
|
|
def update?
|
|
user.is_moderator?
|
|
end
|
|
|
|
def permitted_attributes_for_create
|
|
[:replacement_url, :replacement_file, :final_source, :tags]
|
|
end
|
|
|
|
def permitted_attributes_for_update
|
|
[:old_file_ext, :old_file_size, :old_image_width, :old_image_height,
|
|
:old_md5, :file_ext, :file_size, :image_width, :image_height, :md5,
|
|
:original_url, :replacement_url]
|
|
end
|
|
end
|