From 2a4de3e8694c94b50e287cccf00b9b274f79305c Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 27 Apr 2016 15:59:34 +0200 Subject: [PATCH] Use PictureUploader on Venue --- app/controllers/admin/venues_controller.rb | 2 +- app/models/venue.rb | 6 +----- app/views/admin/venues/_form.html.haml | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/venues_controller.rb b/app/controllers/admin/venues_controller.rb index 903357dc..a049ea7c 100644 --- a/app/controllers/admin/venues_controller.rb +++ b/app/controllers/admin/venues_controller.rb @@ -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 diff --git a/app/models/venue.rb b/app/models/venue.rb index 41b12389..10cf4fcc 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -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 diff --git a/app/views/admin/venues/_form.html.haml b/app/views/admin/venues/_form.html.haml index 00f3e501..5b93cac0 100644 --- a/app/views/admin/venues/_form.html.haml +++ b/app/views/admin/venues/_form.html.haml @@ -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