On the creation of a member the member''s picture uploads as it should. However, when updating the member, while selecting a new picture, an error is thrown: can''t convert nil into String RAILS_ROOT: /Users/chris/Documents/Projects/Rails/CommunityCMS/trunk Application Trace | Framework Trace | Full Trace vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in `join'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in `full_filename'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:281:in `temp_paths'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:275:in `temp_path'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:241:in `save_attachment?'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:344:in `set_size_from_temp_path'' vendor/rails/activerecord/lib/active_record/callbacks.rb:307:in `send'' If I update the user without selecting a new picture, the users picture is lost (the db row values are set to nil) Here is the controller code for the update: -------------------------------- def update @member = Member.find(params[:id]) #try to not set the photo if a new one is not uploaded @photo = @member.build_photo(params[:photo]) unless params[:photo].nil? respond_to do |format| if @member.update_attributes(params[:member]) .... end end Here is the Member model code: ------------------------- class Member < ActiveRecord::Base validates_presence_of :first_name, :last_name, :city, :region, :region_code has_many :groups, :through => :group_members has_one :photo, :as => "photo_for" validates_associated :photo end Here is the file_system_backend (where the error is occurring): ----------------------------------------------- def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s #here is the join that is failing #logger.info "rails root:" + RAILS_ROOT => /Users/... #logger.info "file sys path" + file_system_path => public/photos #logger.info thumbnail => nothing show up here File.join(RAILS_ROOT, file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) end The photo model is polymorphic which is why it exists as a separate model. I have never had this problem before, but this is the first polymorphic relation that I have used to link to the uploaded images. Thanks for the help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Some of the issues above have been fixed, but I am still having problems uploading a photo when editing a member that was created without a photo. It is failing in the exact same spot. Thanks for the help. ============================TypeError in Admin/membersController#update can''t convert nil into String RAILS_ROOT: /Users/chris/Documents/Projects/Rails/CommunityCMS/trunk Application Trace | Framework Trace | Full Trace vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in `join'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in `full_filename'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:281:in `temp_paths'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:275:in `temp_path'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:241:in `save_attachment?'' vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:344:in `set_size_from_temp_path'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `callback'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `each'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `callback'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:269:in `valid?'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:933:in `save_without_transactions'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in `save'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:in `transaction'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in `transaction'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in `save'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in `rollback_active_record_state!'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in `save'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:30:in `replace'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:86:in `new_record'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:18:in `build'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:1114:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:1114:in `build_photo'' app/controllers/admin/members_controller.rb:75:in `update'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello, i having troubles when try replace existing file for new, get the same error... some one can help? On 31 dez 2007, 03:24, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Some of the issues above have been fixed, but I am still having problems > uploading a photo when editing a member that was created without a > photo. > > It is failing in the exact same spot. > > Thanks for the help. > > ============================> TypeError in Admin/membersController#update > > can''t convert nil into String > RAILS_ROOT: /Users/chris/Documents/Projects/Rails/CommunityCMS/trunk > > Application Trace | Framework Trace | Full Trace > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in > `join'' > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in > `full_filename'' > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:281:in > `temp_paths'' > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:275:in > `temp_path'' > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:241:in > `save_attachment?'' > vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:344:in > `set_size_from_temp_path'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in > `send'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in > `callback'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in > `each'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in > `callback'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:269:in > `valid?'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:933:in > `save_without_transactions'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in > `save'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in > `transaction'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:in > `transaction'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in > `transaction'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in > `save'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in > `rollback_active_record_state!'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:108:in > `save'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:30:in > `replace'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:86:in > `new_record'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:18:in > `build'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:1114:in > `send'' > /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:1114:in > `build_photo'' > app/controllers/admin/members_controller.rb:75:in `update'' > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Daniel Lopes wrote:> Hello, i having troubles when try replace existing file for new, get > the same error... some one can help? > > On 31 dez 2007, 03:24, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>The problem for me was that I was missing the unless params[:photo].nil? condition in the create method, which messed up the data when trying to do the update. If that doesn''t help you out at all, post some of your code so we can take a look at it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Chris, i post my question and code in another post in this link, http://groups.google.de/group/rubyonrails-talk/browse_thread/thread/f2510dfd535ebaf0 On 22 jan, 22:46, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Daniel Lopes wrote: > > Hello, i having troubles when try replace existing file for new, get > > the same error... some one can help? > > > On 31 dez 2007, 03:24, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > The problem for me was that I was missing the unless params[:photo].nil? > condition in the create method, which messed up the data when trying to > do the update. > > If that doesn''t help you out at all, post some of your code so we can > take a look at it. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---