Skip to content

Commit

Permalink
[#345 state:resolved] handle creating STI base along with subclasses …
Browse files Browse the repository at this point in the history
…in migration generator
  • Loading branch information
al2o3cr committed Nov 30, 2009
1 parent 9b886e5 commit a91c0bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hobofields/lib/hobo_fields/migration_generator.rb
Expand Up @@ -76,7 +76,7 @@ def load_rails_models
# ActiveRecord::Base, excluding anything in the CGI module
def table_model_classes
load_rails_models
ActiveRecord::Base.send(:subclasses).where.descends_from_active_record?.reject {|c| c.name.starts_with?("CGI::") }
ActiveRecord::Base.send(:subclasses).reject {|c| (c.base_class != c) || c.name.starts_with?("CGI::") }
end


Expand Down
5 changes: 3 additions & 2 deletions hobofields/lib/hobo_fields/model_extensions.rb
Expand Up @@ -25,12 +25,13 @@ def self.inherited(klass)
fields do |f|
f.field(inheritance_column, :string)
end
index(inheritance_column) unless index_specs.*.fields.include?([inheritance_column])
index(inheritance_column)
super
end

def self.index(fields, options = {})
index_specs << HoboFields::IndexSpec.new(self, fields, options)
# don't double-index fields
index_specs << HoboFields::IndexSpec.new(self, fields, options) unless index_specs.*.fields.include?(Array.wrap(fields).*.to_s)
end


Expand Down

0 comments on commit a91c0bd

Please sign in to comment.