Skip to content

Commit

Permalink
💄 Display drinks in higher resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
YtvwlD committed Jun 27, 2023
1 parent 7aca367 commit 88120eb
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/drink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/views/drinks/_drink.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/drinks/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/wrapped/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
1 change: 1 addition & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion test/functional/api/v1/drinks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 88120eb

Please sign in to comment.