Jonathan Fagan
2009-Sep-09 15:09 UTC
Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch Going Nuts!
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!
-J
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
codex1
2009-Sep-10 07:54 UTC
Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch Going Nuts!
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!
-J
Reasonably Related Threads
- Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch
- Controllers in folders and helper scope in Rails >1.0
- AssociationTypeMismatch with RSpec 1.0.8, autotest running with drb
- Validation problems: ActiveRecord::AssociationTypeMismatch
- Validation problem with active record: AssociationTypeMismatch