Use PictureUploader on Lodging

This commit is contained in:
Henne Vogelsang 2016-04-27 15:27:33 +02:00
parent 40023044af
commit 0ad3ff01c3
5 changed files with 11 additions and 17 deletions

View file

@ -47,7 +47,7 @@ module Admin
private private
def lodging_params def lodging_params
params.require(:lodging).permit(:name, :description, :photo, :website_link, :conference_id) params.require(:lodging).permit(:name, :description, :picture, :picture_cache, :website_link, :conference_id)
end end
end end
end end

View file

@ -3,10 +3,5 @@ class Lodging < ActiveRecord::Base
validates :name, presence: true validates :name, presence: true
has_attached_file :photo, mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :photo,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { in: 0..500.kilobytes }
end end

View file

@ -12,8 +12,8 @@
= f.input :name = f.input :name
= f.input :website_link = f.input :website_link
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
- unless @lodging.photo.blank? - if @lodging.picture?
= image_tag @lodging.photo(:thumb) = image_tag @lodging.picture.thumb.url
= f.input :photo = f.input :picture
%p.text-right %p.text-right
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -10,15 +10,15 @@
- slice.each do |lodging| - slice.each do |lodging|
.col-md-4 .col-md-4
.thumbnail .thumbnail
- if lodging.photo.blank? - if !lodging.picture?
%p.text-center %p.text-center
%i.fa.fa-home.fa-5x %i.fa.fa-home.fa-5x
- else - else
-if lodging.website_link.present? -if lodging.website_link.present?
= link_to(lodging.website_link, class: 'thumbnail') do = link_to(lodging.website_link, class: 'thumbnail') do
= image_tag lodging.photo(:thumb), class: 'img-responsive img-lodging' = image_tag lodging.picture.thumb, class: 'img-responsive img-lodging'
- else - else
= image_tag lodging.photo(:thumb), class: 'img-responsive img-lodging' = image_tag lodging.picture.thumb, class: 'img-responsive img-lodging'
.caption .caption
%h3.text-center %h3.text-center
= lodging.name = lodging.name

View file

@ -13,18 +13,17 @@
- slice.each do |lodging| - slice.each do |lodging|
.col-md-4.col-sm-4.ticket.col-centered.col-top .col-md-4.col-sm-4.ticket.col-centered.col-top
.thumbnail .thumbnail
- if lodging.photo.blank? - if !lodging.picture?
%p.text-center %p.text-center
%i.fa.fa-home.fa-5x %i.fa.fa-home.fa-5x
- else - else
-if lodging.website_link.present? -if lodging.website_link.present?
= link_to(lodging.website_link, class: 'thumbnail') do = link_to(lodging.website_link, class: 'thumbnail') do
= image_tag lodging.photo(:large), class: 'img-responsive img-lodging' = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging'
- else - else
= image_tag lodging.photo(:large), class: 'img-responsive img-lodging' = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging'
.caption .caption
%h3.text-center %h3.text-center
= lodging.name = lodging.name
-if lodging.description.present? -if lodging.description.present?
= markdown(lodging.description) = markdown(lodging.description)