Search code examples
ruby-on-railsasset-pipelineminimagick

Rails-MiniMagick open file from controller


Simple question that I am having trouble with. I'm using MiniMagick and I want to open an image file from my controller that is stored in my assets/images file but not having luck. I keep getting 'No such file or directory @ rb_sysopen'. Here is what I have. Any help would be appreciated.

def create
  source= MiniMagick::Image.open('/assets/images/background001.jgp')
end

Solution

  • Your filename extension is transposed. ;)

     /assets/images/background001.**jgp**  vs. **.jpg**
    

    The leading / references the root of the machine.

    Use.

    source= MiniMagick::Image.open('app/assets/images/background001.jpg')