I collaborate with the application, and sometimes I encounter problems related to the fact that the original developer worked in Linux, and I in OSX. My current problem is loading images using ImageMagik and paperclip. When I try to load pic in the application, I get the following message.
Permission denied - /assets
I am sure that this means that the application wanted to save the image somewhere in the resource directory, but could not, because it does not exist on my machine.
In a model, this is code that refers to photographs.
has_attached_file :avatar, :url => "/avatars/:id?style=:style", :styles => { :large => "190x190#", :medium => "70x70#", :thumb => "106x106#" }, :path => "/assets/rob/images/Users/:id/:style/:basename.:extension"
Now I assume that this directory exists on the programmer's source computer and wherever the site is located. But I do not have this directory, so I did this:
:path => "~/robotimus/dev_images/:id/:style/:basename.:extension"
But now I am in pickling, as in the end I will have to return this line before I turn around. As a solution, I could write such a method.
def images_path Rails.env.production? ? "/assets/rob/images/Users/" : "~/robotimus/dev_images" end
And then the path line will look like this:
:path => images_path + "/:id/:style/:basename.:extension"
Does that sound like a good idea? Also, where should this method be stored? I assume it belongs to config / environment.rb, but I would like to get an expert opinion.