Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Display drinks in higher resolution #141

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 => "640x640#" }, :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
Loading