Hi,
I have been trying to do this for a few days now and cannot figure it out. I would be very grateful is anyone can help me
I am trying to upload an attachment to AWS, S3 using paperclip, however every time I keep getting this error:
ActiveRecord::AssociationTypeMismatch in ProjectController#create_notice
Graphic(#37649720) expected, got Tempfile(#27280470)
RAILS_ROOT: C:/devlopment_tools/projects/codex1/active/bugtrigger Application Trace | Framework Trace | Full Trace
c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/associations/association_proxy.rb:263:in `raise_on_type_mismatch' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/associations/has_one_association.rb:52:in `replace' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/associations.rb:1246:in `graphic=' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:2740:in `send' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:2740:in `attributes=' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:2736:in `each' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:2736:in `attributes=' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:2434:in `initialize' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:721:in `new' c:/devlopment_tools/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/ lib/ active_record/base.rb:721:in `create' C:/devlopment_tools/projects/codex1/active/bugtrigger/app/controllers/ project_controller.rb:128:in `create_notice'
The code is:
--Notice Model class Notice < ActiveRecord::Base has_many :graphics end
--Project Controller def create_notice @notice = Notice.create(params[:notice]) end
--Form <%= form.file_field(:graphic) %>
--Graphic class Graphic < ActiveRecord::Base belongs_to :notice attr_accessor :notice_id has_attached_file :graphic, :storage => :s3, :s3_credentials => RAILS_ROOT + "/config/ s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => "attachements" end
Thanks!