I am trying to upload a file (pretty simple stuff right?), but keep getting the argument error. I have cross referenced what I have to prior uses and cannot find any errors with what I have. --------- /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:18:in `initialize'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:18:in `new'' /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/has_one_association.rb:83:in `new_record'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1693:in `with_scope'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:83:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:83: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/accounts_controller.rb:8:in `create''-------- Here is the controller code that is causing the error: def create @account = Account.new(params[:account]) @account.build_photo(params[:photo]) unless params[:photo]["filename"].blank? @user = @account.users.build(params[:user]) if @account.save ... else render :action => "new" end end Here is my model file: class Account < ActiveRecord::Base has_many :agents has_many :users has_one :photo, :as => :photo_for validates_associated :photo, :if => :has_photo? end If I include puts params[:photo].inspect in the controller it does show me there is a datastream there ----- {"filename"=>#<ActionController::UploadedStringIO:0x2519cc4>} 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 -~----------~----~----~----~------~----~------~--~---
Chris Olsen
2008-Jan-24 23:59 UTC
Re: Uploading files: wrong number of arguments (1 for 0)
I don''t know what it is about posting to a forum, but a problem that has confused the hell out of you for an hour tends to become clear after posting here. The issue was an initialize method that preset some variables in the model. -- 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 -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- Attachment_fu problems on updates
- attachment_fu and/or rmagick on osx -- weird error
- [CruiseControl] RubyOnRails build 8649 failed
- User.protected_attributes returning empty Set instead of nil -- causing activerecord/lib/base:2307 to raise
- Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch Going Nuts!