Files
nairobi/app/models/concerns/imageable.rb
iagirre c67620fdef Table for links added (links to add images/documents).
Custom partial for admins upload image created, so that it can be reused in upload images and documents.
2017-09-29 14:51:49 +02:00

16 lines
535 B
Ruby

# can [:update, :destroy ], Image, :imageable_id => user.id, :imageable_type => 'User'
# and add a feature like forbidden/without_role_images_spec.rb to test it
module Imageable
extend ActiveSupport::Concern
included do
has_one :image, as: :imageable, dependent: :destroy
has_many :images, as: :imageable, dependent: :destroy
accepts_nested_attributes_for :image, allow_destroy: true, update_only: true
def image_url(style)
image.attachment.url(style) if image && image.attachment.exists?
end
end
end