Skip to content

Instantly share code, notes, and snippets.

@tibra
Created August 4, 2010 15:27
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 tibra/508301 to your computer and use it in GitHub Desktop.
Save tibra/508301 to your computer and use it in GitHub Desktop.
class Game < ActiveRecord::Base
has_many :photos, :as => :picturable, :dependent => :destroy
accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => lambda { |a| a[:picture].blank? }
end
should be outsourced into a module like
=> /lib/attachment.rb
module Attachment
def has_attachment
has_many :photos, :as => :picturable, :dependent => :destroy
accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => lambda { |a| a[:picture].blank? }
end
end
Is it possible to include it like this?
class Game < ActiveRecord::Base
include Attachment
has_attachment
end
I get some "uninitialized constant Team::Game" where Team is Game's parent class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment