Skip to content

Commit

Permalink
Refactoring code.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosbrando committed Jun 16, 2010
1 parent c772819 commit 4d36a4b
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions Support/bin/list_columns.rb
Expand Up @@ -88,15 +88,7 @@ def cache_attributes
require "#{TextMate.project_directory}/config/environment" require "#{TextMate.project_directory}/config/environment"


Dir.glob(File.join(Rails.root, "app/models/**/*.rb")) do |file| Dir.glob(File.join(Rails.root, "app/models/**/*.rb")) do |file|
begin klass = File.basename(file, '.*').camelize.constantize rescue nil
klass = file.sub(Rails.root.to_s + '/app/models/', '').sub('.rb', '').camelize.constantize
rescue LoadError
begin
klass = File.basename(file, '.*').camelize.constantize
rescue LoadError
klass = nil
end
end


if klass and klass.class.is_a?(Class) and klass.ancestors.include?(ActiveRecord::Base) if klass and klass.class.is_a?(Class) and klass.ancestors.include?(ActiveRecord::Base)
_cache[klass.name.underscore] = { :associations => klass.reflections.stringify_keys.keys, :columns => klass.column_names } _cache[klass.name.underscore] = { :associations => klass.reflections.stringify_keys.keys, :columns => klass.column_names }
Expand Down

0 comments on commit 4d36a4b

Please sign in to comment.