Sha256: b71b65c40d3f6412aacbffa05f3163d63785543cfbda0d9799bf59e8e0dd6edf
Contents?: true
Size: 656 Bytes
Versions: 2
Compression:
Stored size: 656 Bytes
Contents
module Automigration module Fields class BelongsTo < Sys::Base def to_db_columns [db_column_for_standart_types(:type => :integer, :name => "#{@name}_id")] end def extend_model!(model) super model.belongs_to @name, :class_name => @options[:class_name], :inverse_of => @options[:inverse_of] if @options[:accessible] model.attr_accessible "#{@name}_id" end end def assert_options! raise "wrong name '#{@name}'" if @name =~ /_id$/ end def valid_options_keys super + [:class_name, :inverse_of] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
automigration-0.2.2 | lib/automigration/fields/belongs_to.rb |
automigration-0.2.1 | lib/automigration/fields/belongs_to.rb |