Paperclip in Production with Unicorn: uninitialize

2019-07-18 02:21发布

I added Paperclip to my app then tried to deploy to my VPS using capistrano. The deploy happens successfully, but when I try to access my app on the VPS, I get the Rails Error Page. There is no information in production.log, but unicorn.log has the following error:

E, [2013-06-25T19:44:07.372060 #21995] ERROR -- : uninitialized constant Paperclip (NameError)
/home/deployer/apps/arcsite/releases/20130625182331/config/initializers/paperclip.rb:1:in `<top (required)>'

The initializer file is paperclip.rb and has these contents:

Paperclip.interpolates :zone do |attachment, style|
  attachment.instance.zone_id
end

It's an interpolater to allow me to use the folder structure I want.

If I remove the paperclip.rb initializer file, I get an error that has_attachment is undefined in my class, making it seem like the paperclip gem isn't being properly loaded.

I tried to uninstall/reinstall the gem, but when I ran gem uninstall paperclip, it told me that the paperclip gem was not installed. When I ran bundle show paperclip it did show a directory (I'm using RVM), so I manually installed the paperclip gem with gem install paperclip. I'm still getting the same error.

This app works fine in development on the thin server.

My VPS setup:

  • nginx
  • unicorn
  • rvm
  • capistrano

rails version: 3.2.13 paperclip version: 3.4.2

I followed Ryan's screencast to set up nginx/unicorn

2条回答
再贱就再见
2楼-- · 2019-07-18 02:53

So the problem was that unicorn wasn't recognizing my newly installed gems, all I had to do was simply manually stop and then manually start unicorn and everything got taken care of. I had this exact same issue after deploying my app with paperclip installed.

In the application's root directory through SSH--

service unicorn_"app name" stop

followed by

service unicorn_"app name" start
查看更多
孤傲高冷的网名
3楼-- · 2019-07-18 03:06

Turns out it was some weird installation behavior. Had to work with the RVM people and have updated the rvm capistrano documentation to reflect the new procedures.

查看更多
登录 后发表回答