Выполняется
Rails 6.0.2.1
Ruby 2.6.5
Я реализую загрузку фотографий с помощью ActiveStorage и DropZone JS, но на данный момент это вызывает ошибку на этой конкретной странице /users/2
.
Лучше ошибки показывает это
URI::InvalidURIError at /users/2
bad URI(is not URI?): nil
модель автомобиля
def cover_photo(size_x, size_y)
if self.photos.length > 0
self.photos[0].variant(resize_to_limit: [size_x, size_y]).processed.service_url
else
"blank.jpg"
end
end
end
Мой файл журнала
Started GET "/users/2" for ::1 at 2020-05-08 11:39:09 +0000
Processing by UsersController#show as HTML
Parameters: {"id"=>"2"}
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
↳ app/controllers/users_controller.rb:3:in `show'
Rendering users/show.html.erb within layouts/application
[1m[36mCar Load (0.1ms)[0m [1m[34mSELECT "cars".* FROM "cars" WHERE "cars"."user_id" = ?[0m [["user_id", 2]]
↳ app/views/users/show.html.erb:29
[1m[36mActiveStorage::Attachment Load (0.1ms)[0m [1m[34mSELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = ? AND "active_storage_attachments"."record_type" = ? AND "active_storage_attachments"."name" = ?[0m [["record_id", 1], ["record_type", "Car"], ["name", "photos"]]
↳ app/models/car.rb:14:in `cover_photo'
[1m[36mActiveStorage::Blob Load (0.1ms)[0m [1m[34mSELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?[0m [["id", 26], ["LIMIT", 1]]
↳ app/models/car.rb:15:in `cover_photo'
[36m Disk Storage (0.0ms) [0m[34mChecked if file exists at key: variants/4u0kx27vmugn57zwn96o2t27mr71/36e628c6ec62cc8383a3ee5c0c8433e912780efead13846813a9f63693dd17eb (yes)[0m
[36m Disk Storage (0.5ms) [0m[34mGenerated URL for file at key: variants/4u0kx27vmugn57zwn96o2t27mr71/36e628c6ec62cc8383a3ee5c0c8433e912780efead13846813a9f63693dd17eb ()[0m
Rendered users/show.html.erb within layouts/application (Duration: 18.4ms | Allocations: 4342)
Completed 500 Internal Server Error in 21ms (ActiveRecord: 0.4ms | Allocations: 5357)
URI::InvalidURIError - bad URI(is not URI?): nil:
app/models/car.rb:15:in `cover_photo'
app/views/users/show.html.erb:36
app/views/users/show.html.erb:32
Started POST "/__better_errors/f90fad0cb966afba/variables" for ::1 at 2020-05-08 11:39:09 +0000
Как мне это исправить? А что не так с cover_photo
?