0

Well, i'm a new linux/rails student and some problems I just get so blind to solve. I've been digging stackoverflow and google to solve this one, but sincerly I cant. Only thing I know that is related with chmod and chown commands. "Anuncios" is my table as you can see.

error image: enter image description here

I known the error reason is paperclip because I can create a entry without uploading a image. App running in Ubuntu. RoR 4.

Thanks.

strivedi183
  • 4,749
  • 2
  • 31
  • 38
LucasZM
  • 13
  • 2
  • Have you specified a path option in has_attached_file? It seems like there is no write access on the uploaded file path. So you are getting error while saving the record with an image. – Kirti Thorat Mar 09 '14 at 02:42
  • By default, uploaded file path is ':rails_root/public/system/:class/:attachment/:id_partition/:style/:filename' Probably, if this path not exists - permission denied occures – Vitalyp Mar 09 '14 at 02:55
  • 1
    If the path doesn't exist then it is created by paperclip. I think the problem is with permissions or ownership. Paperclip created the system folder and tried to create a sub folder anuncios in it and that resulted in error as the permission was denied. – Kirti Thorat Mar 09 '14 at 03:01
  • Hmm, thats is more reasonable. I've tried something about permissions and ownership and but doenst work. I'll post my permissions later. This is a better way to solve it than reinstalling ImageMagick as me and Vitalyp spoked, isnt it? Edit: alright, here is my permissions and ownership to dir bin, at /usr/: drwxrwxrwx 2 root root 65536 Fev 11 23:33 bin – LucasZM Mar 09 '14 at 07:08
  • And I wonder if the problem is related with permissions/ownership; in the same project there's another table where I upload images and it works fine (this one I get made by a coworker). If this first uploader works, any other that comes after should work fine as well. – LucasZM Mar 09 '14 at 09:17

2 Answers2

0

/Anuncios isn't your table (maybe, you mean desktop?). Your Desktop at ~/Desktop -or- /home/Anuncios/Desktop

/Anuncios looks like 'system dir', and it not exists

Vitalyp
  • 1,069
  • 1
  • 11
  • 20
  • Hello, Vitalyp. Sorry, maybe I'm confusing some concepts. Anuncios is my table at db, as Anuncio is the model and anuncios_controller is my controller - Am I wrong? The only /anuncios that I found is view dir, at "myapp/app/view/anuncios", where is located new.html.erb and etc. – LucasZM Mar 09 '14 at 02:32
  • What is your 'has_attached_file :' arguments? – Vitalyp Mar 09 '14 at 02:42
  • has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" same as documentation – LucasZM Mar 09 '14 at 02:45
  • ..and where you store uploaded files? check the 'config.paperclip_defaults' option. – Vitalyp Mar 09 '14 at 02:50
  • I guess is this /usr/bin/, as development.rb file points: #Paperclip Paperclip.options[:command_path] = "/usr/bin/" config.assets.debug = true I dont saw this as a possible source of error because i'm coding on a existing project with another upload image method using paperclip. – LucasZM Mar 09 '14 at 02:56
  • You need change this location. Paperclip cannot access that folder. – Vitalyp Mar 09 '14 at 02:58
  • Paperclip.options[:command_path] is a path to executable module, it is not that you need – Vitalyp Mar 09 '14 at 03:00
  • Paperclip.options[:command_path] just tells paperclip where ImageMagick is installed. – Kirti Thorat Mar 09 '14 at 03:03
  • So, should I change the dir where ImageMagick drops the images? I saw some problem solved that way or something nearly liked. – LucasZM Mar 09 '14 at 03:05
  • Yep. Look for 'config.paperclip_defaults' configuration options. Reread the gem manual. – Vitalyp Mar 09 '14 at 03:09
  • Ok, I'll try. Thanks Vitalyp and Kirti Thorat. – LucasZM Mar 09 '14 at 03:13
0

SOLVED!

A coworker of mine help me and he said that in my controller I was using a rails 4 convetion [put filtrated params -> @anuncio = Anuncio.new(anuncio_params)] that used to be at model in rails 3; sometimes rails bug out due this change. Just swift anuncio_params by params[:anuncio].

TL,DR:

Sometimes rails bugs due some syntax version changes. Just substitute in my controller this: #@anuncio = Anuncio.new(anuncio_params) for this: @anuncio = Anuncio.new(params[:anuncio]) and works!

Thanks Vitalyp and Kirti Thorat for the contribution. Ps: nothing relative to Image Magick.

LucasZM
  • 13
  • 2