<%= image_tag @supply.supply_photo.variant(resize: "400x400") %>
This is what I have in my view. @supply.supply_photo works for the orginal unsized image. My image is a webp... I turned it into a jpg with the same result. I feel like I am missing something simple but can figure out what I am missing.
The error I get is ActiveStorage::InvariableError
My log reads
Started PUT "/__web_console/repl_sessions/cbaf86fd1070dd817c45101a6cf549f0" for ::1 at 2020-08-09 19:21:08 -0700
Started PUT "/__web_console/repl_sessions/cbaf86fd1070dd817c45101a6cf549f0" for ::1 at 2020-08-09 19:21:09 -0700
Started GET "/supplies/1" for ::1 at 2020-08-09 19:21:57 -0700
Processing by SuppliesController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]]
↳ app/controllers/concerns/set_current_request_details.rb:11:in `block (2 levels) in <module:SetCurrentRequestDetails>'
Account Load (0.8ms) SELECT "accounts".* FROM "accounts" INNER JOIN "account_users" ON "accounts"."id" = "account_users"."account_id" WHERE "account_users"."user_id" = $1 AND "accounts"."id" IS NULL LIMIT $2 [["user_id", 2], ["LIMIT", 1]]
↳ app/controllers/concerns/set_current_request_details.rb:24:in `block (2 levels) in <module:SetCurrentRequestDetails>'
Account Load (0.8ms) SELECT "accounts".* FROM "accounts" INNER JOIN "account_users" ON "accounts"."id" = "account_users"."account_id" WHERE "account_users"."user_id" = $1 ORDER BY "accounts"."created_at" ASC LIMIT $2 [["user_id", 2], ["LIMIT", 1]]
↳ app/controllers/concerns/set_current_request_details.rb:29:in `block (2 levels) in <module:SetCurrentRequestDetails>'
Supply Load (0.5ms) SELECT "supplies".* FROM "supplies" WHERE "supplies"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/supplies_controller.rb:51:in `set_supply'
Rendering supplies/show.html.erb within layouts/application
ActiveStorage::Attachment Load (0.4ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 1], ["record_type", "Supply"], ["name", "supply_photo"], ["LIMIT", 1]]
↳ app/views/supplies/show.html.erb:17
ActiveStorage::Blob Load (0.4ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 3], ["LIMIT", 1]]
↳ app/views/supplies/show.html.erb:17
Rendered supplies/show.html.erb within layouts/application (Duration: 7.3ms | Allocations: 2886)
Completed 500 Internal Server Error in 25ms (ActiveRecord: 3.6ms | Allocations: 6842)
ActionView::Template::Error (ActiveStorage::InvariableError):
14: <h5>Url</h5>
15: <%= @supply.url %>
16: </div>
17: <%= image_tag @supply.supply_photo.variant(resize_to_limit: "400x400") %>
18: </div>
19: </div>
20: </div>
app/views/supplies/show.html.erb:17
This fixed my issue
<%= image_tag @supply.supply_photo.variant(resize_to_limit: [400, 400]) %>