Henry Turner
2006-Jul-20 19:40 UTC
[Rails] file_column - assigning with an actual file rather than a multipart
Hi there, I''m using the wonderful file_column and have struck an issue that someone might have seen before. My images already sit on the server. So, instead of passing a multipart message I''m sending a file object. Something like... f = File.new("public/gallery_images/builder.png") p = Product.find_first p.image = f p.save On the save I recieve an error which I''ve pasted at the bottom of this mail. A temporary image is created in the correct place so I''m almost there. Any ideas? I haven''t heard of anyone doing this but file_column.rb#47 said I could. Thanks -h NoMethodError: undefined method `empty?'' for 0:Fixnum from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:351:in `initialize'' from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:135:in `clone_as'' from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:309:in `after_save'' from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:673:in `image_after_save'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:333:in `callback'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:330:in `callback'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:250:in `create_or_update'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:1392:in `save_without_validation'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/validations.rb:724:in `save_without_transactions'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:126:in `save'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:91:in `transaction'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:118:in `transaction'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:126:in `save'' from (irb):17
Henry Turner
2006-Jul-21 12:25 UTC
[Rails] file_column - assigning with an actual file rather than a multipart
Oops, dont worry about that... I had the field type set to integer rather than string. Good one dumbdumb. -h On 7/20/06, Henry Turner <lovecider@gmail.com> wrote:> Hi there, > > I''m using the wonderful file_column and have struck an issue that > someone might have seen before. > > My images already sit on the server. So, instead of passing a > multipart message I''m sending a file object. > > Something like... > > f = File.new("public/gallery_images/builder.png") > p = Product.find_first > p.image = f > p.save > > On the save I recieve an error which I''ve pasted at the bottom of this mail. > > A temporary image is created in the correct place so I''m almost there. > Any ideas? I haven''t heard of anyone doing this but file_column.rb#47 > said I could. > > Thanks > -h > > > > > > NoMethodError: undefined method `empty?'' for 0:Fixnum > from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:351:in > `initialize'' > from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:135:in > `clone_as'' > from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:309:in > `after_save'' > from ./script/../config/../config/../vendor/plugins/file_column/lib/file_column.rb:673:in > `image_after_save'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:333:in > `callback'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:330:in > `callback'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.rb:250:in > `create_or_update'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:1392:in > `save_without_validation'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/validations.rb:724:in > `save_without_transactions'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:126:in > `save'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in > `transaction'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:91:in > `transaction'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:118:in > `transaction'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactions.rb:126:in > `save'' > from (irb):17 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >