diff --git a/app/models/drink.rb b/app/models/drink.rb index bd2bc845..22a71629 100644 --- a/app/models/drink.rb +++ b/app/models/drink.rb @@ -5,7 +5,7 @@ class Drink < ApplicationRecord validates :name, :bottle_size, :price, presence: true - has_attached_file :logo, :styles => { :thumb => "100x100#" }, :default_style => :thumb + has_attached_file :logo, :styles => { :thumb => "100x100#", :medium => "500x500#" }, :default_style => :medium validates_attachment_content_type :logo, :content_type => %w(image/jpeg image/jpg image/png) before_post_process :normalize_filename after_initialize :set_defaults, unless: :persisted? diff --git a/app/views/drinks/_drink.html.haml b/app/views/drinks/_drink.html.haml index 3288d048..d313439a 100644 --- a/app/views/drinks/_drink.html.haml +++ b/app/views/drinks/_drink.html.haml @@ -7,6 +7,6 @@ .inner-header %h6= drink.name .card-body - = image_tag drink.logo(:thumb), alt: drink.name, class: drink.active? ? "" : "disabled" + = image_tag drink.logo(:medium), alt: drink.name, class: drink.active? ? "" : "disabled", size: 100 .card-footer = show_amount drink.price diff --git a/app/views/drinks/index.html.haml b/app/views/drinks/index.html.haml index 4df07b06..0528f1d4 100644 --- a/app/views/drinks/index.html.haml +++ b/app/views/drinks/index.html.haml @@ -25,7 +25,7 @@ %tr %td = link_to [:edit, drink] do - = image_tag drink.logo(:thumb), class: drink.active ? "" : "disabled" + = image_tag drink.logo(:medium), class: drink.active ? "" : "disabled", size: 100 %th{:scope => "row"}= drink.name %td= drink.bottle_size %td= drink.caffeine diff --git a/app/views/wrapped/show.html.haml b/app/views/wrapped/show.html.haml index 31a40973..ca3b6b41 100644 --- a/app/views/wrapped/show.html.haml +++ b/app/views/wrapped/show.html.haml @@ -14,7 +14,7 @@ .row.g-0 .col-xs-1.col-sm-4.col-md-3.col-lg-2 .wrapped-image - = image_tag @most_bought_drink[:drink].logo(:thumb), alt: @most_bought_drink[:drink].name, class: ['img-fluid', 'rounded-start'] + = image_tag @most_bought_drink[:drink].logo(:medium), alt: @most_bought_drink[:drink].name, class: ['img-fluid', 'rounded-start'], size: 100 .col-md-8.card-body %h5.card-title Your favorite drink is #{@most_bought_drink[:drink].name}. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index c8880b8a..4b23b02f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,5 +6,6 @@ if [ -f /app/tmp/pids/server.pid ]; then fi bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:setup +bundle exec rake paperclip:refresh:missing_styles exec bundle exec "$@" diff --git a/test/functional/api/v1/drinks_controller_test.rb b/test/functional/api/v1/drinks_controller_test.rb index 81de866e..926446b4 100644 --- a/test/functional/api/v1/drinks_controller_test.rb +++ b/test/functional/api/v1/drinks_controller_test.rb @@ -26,7 +26,7 @@ class Api::V1::DrinksControllerTest < ActionController::TestCase assert_nil resp["logo_content_type"] assert_nil resp["logo_file_size"] assert_nil resp["logo_updated_at"] - assert_equal "/logos/thumb/missing.png", resp["logo_url"] + assert_equal "/logos/medium/missing.png", resp["logo_url"] assert_nil resp["created_at"] assert_nil resp["updated_at"] assert_equal true, resp["active"]