Paperclip in Production with Unicorn: uninitialized constant Paperclip (NameError)

假如想象 提交于 2019-12-11 01:27:25

问题


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


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/17306285/paperclip-in-production-with-unicorn-uninitialized-constant-paperclip-nameerro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!