Hi, Firstly, thanks to Sebastian Kanthak for an excellent plugin! It works marvellously for uploading and resizing images, but I''m getting the dreaded url_for_file_column returns nil error. Using: file_column 0.3.1 Rails 0.14.3 Ruby 1.8.2-1 Debian Sarge I am using an instance variable as required in my view. image_relative_path also returns nil. Any pointers? new.rhtml: <%= file_column_field "recipe", "image" %> show.rhtml: <%= image_tag url_for_file_column("recipe", "image") %> controller: @recipe = Recipe.find(params[:id]) (and is confirmed not to be nil) NoMethodError: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.first thanks -- Mark Beattie Easy Schedule Management http://easy-online-schedule.com
Hello Mark, 2005/12/6, Mark Beattie <beattie.mark@gmail.com>:> Firstly, thanks to Sebastian Kanthak for an excellent plugin! It works > marvellously for uploading and resizing images, but I'm getting the dreaded > url_for_file_column returns nil error.Is it possible that @recipe.image is nil ? If that's the case, then that is your problem. You have to code around it: <% if @recipe.image.nil? then -%> <em>No image</em> <% else -%> <%= image_tag url_for_file_column ... %> <% end -%> -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hello François, On Wednesday 07 December 2005 11:13 am, Francois Beausoleil wrote:> Is it possible that @recipe.image is nil ? If that''s the case, then > that is your problem. You have to code around it:Yes, it is nil, which is exactly the problem - this is for a @recipe for which an image has been uploaded, resized, and saved by file_column. I had exactly that same code in place which resulted in no images being displayed at all. Any ideas about where I should be looking for clues? thanks -- Mark Beattie Easy Schedule Management http://easy-online-schedule.com
2005/12/6, Mark Beattie <beattie.mark@gmail.com>:> On Wednesday 07 December 2005 11:13 am, Francois Beausoleil wrote: > > Is it possible that @recipe.image is nil ? If that's the case, then > > that is your problem. You have to code around it: > > Yes, it is nil, which is exactly the problem - this is for a @recipe for which > an image has been uploaded, resized, and saved by file_column.Hmmm, that's bad. Try to open the Rails console and check the recipe manually: ruby script/console r = Recipe.find(ID) r.image r.image should return the path to the image. If that comes back as nil, then your image was never put in the DB in the first place. Check the place where you upload and add debugging information there. You might also want to add an after_save callback to print the path to the image, at least temporarily. Additionaly, unit testing Recipe image uploading might be a good idea. Hope that helps ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Wednesday 07 December 2005 12:02 pm, Francois Beausoleil wrote:> nil, then your image was never put in the DB in the first place.Ah, yes I kinda missed that point somehow - call me stupid but the remedy for me was to make sure the table actually had a column called "file"... Could I just as easily have two files associated with an object, such as an image and an attachment of unknown type using 2 file_column declarations in the model assuming it''s table has a field to store the filename of each? class Foo < ActiveRecord::Base file_column :image, :magick => { :geometry => "640x480>" } file_column :attachment end Sorry to have bothered you, and thanks again. -- Mark Beattie Easy Schedule Management http://easy-online-schedule.com
Hi Mark, I''m glad you like the plugin... On 12/7/05, Mark Beattie <beattie.mark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Could I just as easily have two files associated with an object, such as an > image and an attachment of unknown type using 2 file_column declarations in > the model assuming it''s table has a field to store the filename of each? > > class Foo < ActiveRecord::Base > file_column :image, :magick => { :geometry => "640x480>" } > file_column :attachment > endyes, that works. You''ll need two different columns in your database and two different file upload fields, though. Sebastian