RMagick + Rails + Heroku?

蹲街弑〆低调 提交于 2019-12-02 17:46:41

For Rails3, you have to add this specification:

gem "rmagick", "2.12.0", :require => 'RMagick'

Note: require is CAsE SeNSITIvE

Ok so for future reference heres what needs to be done.

In your .gems file you need:

rmagick

and then in your config/environment.rb file you need:

config.gem "rmagick",
:lib => "RMagick" 

Because its already preinstalled with heroku - this does the trick.

mattwallace

Once I did the following from capps answer.

gem "rmagick", "2.12.0", :require => 'RMagick'

Then I added the require statement to any file uses rmagick it fixed my issue.

require 'RMagick'

This worked on Heroku cedar stack running rails 3.1

It depends on which stack you are using on Heroku. The default Aspen stack includes a lot of gems preloaded. For compatibility reasons, the newer Bamboo stack has no preinstalled gems. It is always better to define your gem dependencies in the .gems manifest or in the new bundler style Gemfile.

More info:
Stacks: http://docs.heroku.com/stack
Gems: http://docs.heroku.com/gems

You should just need to add a require statement in whatever class. It's case sensitive!

mike@sleepycat:~/projects/myapp$ heroku console --app myapp
Ruby console for myapp.heroku.com
>> require 'RMagick'
=> []
>> include Magick
=> Object

I don't have that in my .gems file or anything, and there it is in my console, so it seems that it is just there by default.

I know this post is quite old but I just ran into this myself.

gem 'rmagick', '2.16.0', :require => 'rmagick'

Worked for me. According to my Heroku logs RMagick is deprecated in favor of rmagick (all lower case).

Hope this helps the future Googler.

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