In my app an user has the ability to upload their logo to display on their profile page (using Carrierwave + s3).
On my local app the image path is this: https://s3.amazonaws.com/iemarkt/uploads/user/logo/squaredeye_336x336.jpg
But on my Heroku deployed app the image path is "/assets/", which is causing an error and not letting the user upload the image.
Whenever I try to upload a file with Carrierwave + s3 on my Heroku app I get this error "We're sorry, but something went wrong.", looking into my log I see this error:
2012年08月20日T21:18:56+00:00 app[web.1]: Started GET "/assets/" for 24.90.124.181 at 2012年08月20日 21:18:56 +00002012-08-20T21:18:56+00:00 app[web.1]:2012年08月20日T21:18:56+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets"):
My store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/"
I unccomented this line in my production.rb (I read that Heroku uses Nginx, I dont know if there's something else I need to do to get Nginx to work.)
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
I really don't know why the path doesn't lead to my s3 account.
Here's my app
-
But is saving the images on S3? Try removing this line from your carrierwave.rb: config.fog_host = 's3.amazonaws.com/iemarkt'Tiago– Tiago2012年08月22日 01:17:31 +00:00Commented Aug 22, 2012 at 1:17
-
Its not I get an error on Heroku saying that somethig went wrong.ChrisBedoya– ChrisBedoya2012年08月22日 01:27:22 +00:00Commented Aug 22, 2012 at 1:27
-
But what error it gave? For the log you can see the exact errorTiago– Tiago2012年08月22日 01:41:16 +00:00Commented Aug 22, 2012 at 1:41
-
2012年08月20日T21:18:56+00:00 app[web.1]: Started GET "/assets/" for 24.90.124.181 at 2012年08月20日 21:18:56 +00002012-08-20T21:18:56+00:00 app[web.1]:2012年08月20日T21:18:56+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets"):ChrisBedoya– ChrisBedoya2012年08月22日 01:42:25 +00:00Commented Aug 22, 2012 at 1:42
-
When I look at the broken image link the src is "/assets/" I know thats the error but I dont know how to change it.ChrisBedoya– ChrisBedoya2012年08月22日 01:43:47 +00:00Commented Aug 22, 2012 at 1:43
1 Answer 1
I just tried to deploy your app and it works fine, see my user has an image uploaded
http://young-reaches-9187.herokuapp.com/deals/1
The only thing I changed was in the carrier wave settings, the region name was wrong: you were trying to use the region
'eu-east-1'
which doesn't exists, so I changed it to :
'us-east-1'
The full list of regions is available here : http://docs.amazonwebservices.com/general/latest/gr/rande.html
By the way you SHOULD NOT write your AWS credentials in your app. For instance I just uploaded to your bucket, but I could have detroyed your files. You should use environment variables.
You should also add you database.yml in your .gitignore.
Comments
Explore related questions
See similar questions with these tags.