Reputation: 917
I have seeds.rb
file like this (I use paperclip gem):
player1 = Player.create(
firstname: "John", lastname: "Malkon", nickname: "jonmal",
avatar: File.new("#{Rails.root}/public/examples/avatars/1.png"))
When I run locally rake db:seed
everything works (images work fine).
But when I run heroku run rake db:seed
images don't work.
In the html code I can see:
<img src="/system/players/avatars/000/000/007/medium/7.jpg?1438851753" alt="7">
But image is broken.
What is the problem (I suppose the problem is about path but I don't kton how to fix it)?
I have my image files in public/examples/avatars/
In browser console I get:
"NetworkError: 404 Not Found - http://foosballtr.herokuapp.com/system/players/avatars/000/000/007/medium/7.jpg?1438851753"
Where should I put my image files?
Upvotes: 1
Views: 485
Reputation: 44370
I assume a paperclip
gem takes your image from public/examples/avatars/
and places it to the public/system/players/avatars/
directory.
You can't see your images because, the Heroku
file system is read-only (except /tmp
), hence your images is not persisted.
See the topic here for more info on this limitation.
Uploading Files to S3 in Ruby with Paperclip
Upvotes: 4