Paperclip attachments gone after upgrade to Rails 4.0 - ruby-on-rails

I have a capistrano deployment on my server at:
/srv/www/pitot.io/public_html/pitot/pitot-production
Where within this folder, I have the following:
current releases repo revisions.log shared
My previous installations paperclip files were stored like this, and still exist there:
/srv/www/pitot.io/public_html/pitot/pitot-production/shared/system/airlines/logos/000/001/199/thumb/thumb_asianspirit-b.gif
Now, I have an issue here. In my Airline model, I have the following line:
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png",
:path => ":rails_root/public/system/:class/:attachment/:id/:style/:filename",
:url => "/system/:class/:attachment/:id/:style/:filename"
But the images aren't appearing anymore. In my migration, I changed to nginx and rsynced the folders to the new server, maintaining symbolic links. Is there some symbolic link somewhere that I'm missing?

The issue was that I had upgraded capistrano to the newest version (3.2.1) without noticing that the new version no longer automatically makes a symbolic link between public/system and ../shared/public/system. I have changed this, and it is now correct. It is done by uncommenting the line:
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
in deploy.rb

Related

Errno::ENOENT (No such file or directory # rb_sysopen - aws.yml) in rails with paperclip

Rais application deployed in aws elastic beantalk. Images are not loading from assets folder. I am trying to use s3 bucket to store assets. I got an error...
aws.yml
production:
access_key_id: 123333231331....
secret_access_key: 12212dddddd........
production.rb
config.paperclip_defaults = {
:storage => :s3,
:preserve_files => true,
:s3_credentials => 'aws.yml',
:s3_region => 'ap-south-1',
:s3_host_name => 's3.ap-south-1.amazonaws.com',
:bucket => 'xxxxxx'
}
I also give public access permissions in s3 bucket.
anyone: read write
gem...
gem 'aws-sdk', '~> 2.10', '>= 2.10.85'
aws.yml folder within config folder -- config/aws.yml
Have you tried using the path to the file, as at the bottom of your question: :s3_credentials => 'config/aws.yml'.
Otherwise, you might need to explicitly load the file from YAML and pass this in:
require 'yaml'
...
# again, perhaps using config/aws.yml, have a play
:s3_credentials => YAML.load_file('aws.yml')
...
Either of those help?

Trimming and Compression the image of paperclip using rake task

I want to trimming the image of paperclip in my database.
Because I`m running my own private web service, but I forgot to add the styles when user create the image...
has_attached_file :avatar,
:storage => :s3,
:styles => { # I forgot to add this styles
:medium => "370x370#", # I forgot to add this styles
:thumbs => "120x120#" # I forgot to add this styles
}
So I want to run the rake task and trimming like 370×370# and 120×120#.
But I cant`t find the way to trimming the image after user save.
Does anyone assist me ?
The paperclip gem comes with a rake task for exactly this purpose:
rake paperclip:refresh:thumbnails
Just run that from the command line and it will take care of generating all of your reduced-size images.

frontend UI looks totally different and broken on heroku, how to fix this?

I'm using Amazon S3 buckets to store all of the applications assets, however, the app looks totally different in development than it does in production on heroku. Why might this be?
How can I get it to look the same? I've worked on several apps before and never experienced this issue. Any help would be great at this point!
production.rb:
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
:region => ENV['REGION']
}
}
Thanks!
Run
bundle exec rake assets:precompile RAILS_ENV=production
or
bundle exec rake assets:precompile
on your local code
Commit the changes and deploy to heroku

Image file is not recognized by the 'identify' command. (heroku)

I'm trying to have Paperclip working with Heroku and Amazon S3.
Everything works fine on localhost (mac OS and Amazon), but when I'm deploying to heroku and trying the feature, I have this error :
2 errors prohibited this area from being saved:
Asset /tmp/paris20121005-2-2cwxgx.jpg is not recognized by the 'identify' command.
Asset /tmp/paris20121005-2-2cwxgx.jpg is not recognized by the 'identify' command.
It works when I remove the :styles => { } option in my model, but the file isn't processed (I need different image sizes).
I also have the rmagick gem in my gemfile.
Here is my gemfile (only the paperclip part) :
gem "paperclip"
gem "rmagick", :require => 'RMagick'
gem 'aws-sdk', '~> 1.3.4'
I don't have Paperclip.options[:command_path] set in my environment.rb or production.rb so no problem on this side.
Here is my model :
class Area < ActiveRecord::Base
require 'RMagick'
has_attached_file :asset, :styles => { :medium => "300x300>", :thumb => "180x190>" },
:storage => :s3,
:s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
:url => :s3_domain_url.to_s,
:path => "/:style/:id/:filename"
end
Any clue on that ? I've crawled every topics about it and nothing seems to work...
Thanks
Apparently the new update to Cocaine gem (0.4.0) breaks the file names for Paperclip and ImageMagick. try rolling back to the previous version (0.3.2), it worked for me.
See here:
https://github.com/thoughtbot/paperclip/issues/1038
PS I believe RMagick is no longer needed on Heroku, works fine for me without it

Paperclip Errno::EACCES (Permission denied - /system)

My production environment is : ruby 1.9.2-p320 , rails 3.2.7, paperclip 3.1.4, mysql, Ubuntu 8.10 x86 64bit.
I have a Errno:EACCES Permission denied /system error when i try to upload a file with paperclip. Useless to say that locally this doesn't happen.
I checked the public directory permissions and it's 775, the public/system permission is 777 as well as all it's inner directory. The tmp directory permission is : 775 too.
Moreover the user used to deploy the application is www-data:root
The model's attachment is set like this :
has_attached_file :fichier,
:path => "/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename"
I can't find out why i get this error. Anyone has got an idea ?
Thanks
Your code DOES NOT try to save the uploaded file in:
/path/to/app/public/system/:attachment/:id/:style/:filename
but in:
/system/:attachment/:id/:style/:filename
Try this instead:
has_attached_file :fichier,
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename"

Resources