Finally i have RMagick and the file_column plugin installed, but at the time of uploading images i have trouble, i get "uninitialized constant ArtImage" error and other errors, im following the instructions on http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn but doesnt seems to work, this its the code im using: #----view <%= form_tag({:action=>''create_art_image'', :id=> @art_image}, :multipart => true)%> <%= file_column_field "art_image", "image" %><br/> <%= submit_tag ''Upload'' -%> <%= end_form_tag %> #---controller action def create_art_image @art_image = ArtImage.new(@params[:art_image]) end #----model file_column :image i have my table(items) fields asi this: id int title varchar content text image varchar what i want to do its upload all the images to one folder and then later can be assigned to the items(on the image field im guessing), i just cant figure out how to make this work so if someone have a working example or any advice it will be very helpful. :) -- Posted via http://www.ruby-forum.com/.
Hi Ana, Looking at your code, it looks as though your controller is trying to find a model called ArtImage, but can''t find it. Is that what you''ve named your model? Your model should have the following as the class name: class ArtImage < ActiveRecord::Base. If it is, maybe try restarting your web server, if you haven''t already. Take care, Sean On 28-May-06, at 1:58 PM, Ana Barrueta wrote:> Finally i have RMagick and the file_column plugin installed, but at > the > time of uploading images i have trouble, i get "uninitialized constant > ArtImage" error and other errors, im following the instructions on > http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn but doesnt > seems to work, this its the code im using: > > #----view > <%= form_tag({:action=>''create_art_image'', :id=> > @art_image}, :multipart > => true)%> > <%= file_column_field "art_image", "image" %><br/> > <%= submit_tag ''Upload'' -%> > <%= end_form_tag %> > > #---controller action > def create_art_image > @art_image = ArtImage.new(@params[:art_image]) > end > > #----model > file_column :image > > i have my table(items) fields asi this: > id int > title varchar > content text > image varchar > > what i want to do its upload all the images to one folder and then > later > can be assigned to the items(on the image field im guessing), i just > cant figure out how to make this work so if someone have a working > example or any advice it will be very helpful. > > :) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Yeah Sean, that was the problem, i set up the model and all worked well at least for a while, suddenly the uploads doenst work anymore, when i upload an image the artimage -img -tmp directory its created inside the public directory but no image inside and also a new row on the table its added but null, here its my working(for a minute) code: #----view <%= form_tag({:action=>''create_art_image'', :id=> @art_image}, :multipart => true)%> <%= file_column_field "artimage", "image" %><br/> <%= submit_tag ''Upload'' -%> <%= end_form_tag %> #----controller action def create_art_image @art_image = ArtImage.new(@params[:art_image]) if @art_image.save flash[:notice] = ''Upload sucessful'' redirect_to :action => ''index'' else flash[:notice] = ''Error'' render :action => ''index'' end end #----model file_column :image -- Posted via http://www.ruby-forum.com/.
You''re probably missing the actual ''save'' logic in your ArtImage class. Files inside ''tmp'' directory are only kept between failed submissions, so if you submit the form and everything goes through, at the end of the transaction the tmp folder should be empty. (Which is what seems to be happening in your case). Make sure your save action actually saves the uploaded file somewhere. OR, just to double check this theory, add a ''mandatory'' field, and leave it blank.. Then upload/submit the form with the file and check if you get something in the tmp folder. Ilya -- Posted via http://www.ruby-forum.com/.
ok, i?ve added: validates_presence_of :image to my model, and now everytime i try to upload an image i get the "Error" message from the controller action(when try to save) so im guessing that the file_column_field aren?t passing any parameters to the controller but i cant figure out why, this code worked? and suddenly without any changes stop to work, im really getting upset with this no error signs, no rails exceptions, simply does nothing :( -- Posted via http://www.ruby-forum.com/.