codex1
2009-Sep-10 08:19 UTC
Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch
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!
Sandip Ransing
2009-Sep-10 09:28 UTC
Re: Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch
Try this out On Thu, Sep 10, 2009 at 1:49 PM, codex1 <jfagan365-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > >has_attached_file :graphic, :storage => :s3, :path => ":attachment/:id.:extension", :s3_credentials => open( "#{RAILS_ROOT}/config/s3.yml", ''r'' ), :s3_permissions => ''public-read'', :bucket => ApplicationConfig[ ''s3_buckets'' ][ ''graphics'' ][ ''graphic'' ]> Thanks! > > >-- Ruby on Rails Developer http://funonrails.wordpress.com www.joshsoftware.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 -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch Going Nuts!
- access key error
- Controllers in folders and helper scope in Rails >1.0
- AssociationTypeMismatch with RSpec 1.0.8, autotest running with drb
- Validation problems: ActiveRecord::AssociationTypeMismatch