lib/pry-helper/definition.rb in pry-helper-0.1.0 vs lib/pry-helper/definition.rb in pry-helper-0.1.1

- old
+ new

@@ -103,10 +103,16 @@ def initialize @@models = [] ActiveRecord::Base.connection.tap do |conn| + Rails.root.join("app/models").tap do |path| + Dir.glob("#{path}/**/*.rb").each do |file| + file_name = File.basename(file, '.rb') + file_name.classify.constantize + end + end defined_models = ::ApplicationRecord.descendants tables = conn.tables if conn.adapter_name == 'Mysql2' conn.define_singleton_method(:dump) do |filename, no_create_db=false| PryHelper::Mysqldump.new.dump_database(filename, no_create_db) @@ -122,10 +128,10 @@ ApplicationRecord.include(PryHelper::Extension) tables.each do |table_name| table_comment = comments[table_name] primary_keys[table_name].tap do |pkey| - table_name.camelize.tap do |const_name| + table_name.classify.camelize.tap do |const_name| const_name = 'Modul' if const_name == 'Module' const_name = 'Clazz' if const_name == 'Class' if model_class = defined_models.find { |m| m.table_name == table_name } model_class.tap do |clazz| model_class.name.gsub(/[a-z]*/, '').tap do |bare_abbr|