Files
grecia/app/models/concerns/imageable.rb
iagirre 166caa3b4c Deleted code in views and concerns that lets polls have more images and documentes attached, like it was at first.
Added missing text for english and new texts in english and spanish.

 Cambios para hacer commit:
	modificado:    app/assets/stylesheets/participation.scss
	modificado:    app/models/concerns/imageable.rb
	modificado:    app/models/poll.rb
	modificado:    app/views/admin/poll/polls/_form.html.erb
	modificado:    app/views/images/_admin_image.html.erb
	modificado:    config/locales/en/images.yml
	modificado:    config/locales/es/admin.yml
	modificado:    config/locales/es/images.yml
	modificado:    spec/features/admin/poll/polls_spec.rb
2017-10-02 12:59:26 +02:00

15 lines
477 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
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