Use PictureUploader on Venue

This commit is contained in:
Henne Vogelsang 2016-04-27 15:59:34 +02:00
parent f1f5fc1cd4
commit 2a4de3e869
3 changed files with 6 additions and 10 deletions

View file

@ -44,7 +44,7 @@ module Admin
private
def venue_params
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id)
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :picture, :picture_cache, :lodgings_attributes, :conference_id)
end
end
end

View file

@ -8,11 +8,7 @@ class Venue < ActiveRecord::Base
validates :name, :street, :city, :country, presence: true
validates :conference_id, presence: true, uniqueness: true
has_attached_file :photo,
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :photo,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
before_save :send_mail_notification

View file

@ -8,7 +8,7 @@
= link_to 'Details', '#details-content', 'data-toggle' => 'tab'
%li
= link_to 'Commercials', '#commercials-content', 'data-toggle' => 'tab'
.tab-content
#details-content.tab-pane.active
.col-md-8
@ -16,9 +16,9 @@
= f.inputs :name, :website
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
= f.inputs :street, :postalcode, :city, :country, :latitude, :longitude
- unless @venue.photo.blank?
= image_tag @venue.photo(:thumb)
= f.input :photo
- if @venue.picture?
= image_tag @venue.picture.thumb.url
= f.input :picture
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
#commercials-content.tab-pane