# Uploading files: wrong number of arguments (1 for 0)

**URL:** <https://www.ruby-forum.com/t/uploading-files-wrong-number-of-arguments-1-for-0/127107>\
**Category:** Rails\
**Created:** [January 25, 2008, 12:42am UTC](https://www.ruby-forum.com/t/uploading-files-wrong-number-of-arguments-1-for-0/127107 "2008-01-25T00:42:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [January 25, 2008, 12:42am UTC](https://www.ruby-forum.com/t/uploading-files-wrong-number-of-arguments-1-for-0/127107/1 "2008-01-25T00:42:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [January 25, 2008, 12:59am UTC](https://www.ruby-forum.com/t/uploading-files-wrong-number-of-arguments-1-for-0/127107/2 "2008-01-25T00:59:53Z")

</div>

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.
