I\'m creating a Rails gem that integrates closely with Active Record. The gem requires a number of fields to be defined. For example:
class User < ActiveRecor
I consider t.attached
similar to t.references
in a polymorphic association.
With reference to the references
method you can have something like below
def attached(*args)
options = args.extract_options!
column(:avatar_identifier, :string, options)
column(:avatar_extension, :string, options)
column(:avatar_size, :integer, options)
end
You might like to extend ActiveRecord::ConnectionAdapters::TableDefinition
Have look at this
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-references