Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created May 14, 2012 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agibralter/2694791 to your computer and use it in GitHub Desktop.
Save agibralter/2694791 to your computer and use it in GitHub Desktop.
has_one through does not provide `create_child` method?
class User < ActiveRecord::Base
has_one :image_assignment, as: :imageable
has_one :image, through: :image_assignment
end
class ImageAssignment < ActiveRecord::Base
belongs_to :image
belongs_to :imageable, polymorphic: true
end
class Image < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
u = User.new
u.create_image #=> undefined method `create_image'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment