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.