Irbrc configuration file does not work for rubies 2 + rails 4

Irbrc configuration file runs on rails 3.2 + ruby ​​1.9

Today I checked the project using rails 4 + ruby ​​2,

and I found that it didn’t upload the file .irbrc(I put the file in my home directory)

When I ran into irborrails console

What is the problem?

irbrc file

require 'irb/completion'                                                 
require 'hirb' ; Hirb.enable                                             

ARGV.concat ["--readline", "--prompt-mode", "simple"]                    
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"                  

ActiveRecord::Base.logger.level = 1 # Avoid log in Rails console      
ActiveRecord::Base.logger = Logger.new STDOUT #顯示 SQL statements

ActiveRecord::Base.connection.tables
    def drop_tbl (tblname)
        ActiveRecord::Migration.drop_table(eval(":"+tblname))
    end
    def show_tbls
        tbls = ActiveRecord::Base.connection.tables
        tbls.each { |tbl|
            puts "#{tbl} #{tbl_name(tbl)}"
        }
    end
    def tbl_name(name)
        name.singularize.humanize.split().map{|x| x.capitalize}.join()
    end


    def cols (tblname)
        cols = eval("#{tblname}.column_names")
        ap(cols)
    end

Gemfile in the project

source 'https://rubygems.org'
ruby '2.0.0'

gem 'bootstrap-sass'
gem 'coffee-rails'
gem 'rails'
gem 'haml-rails'
gem 'sass-rails'
gem 'uglifier'
gem 'jquery-rails'

group :development do
  gem 'sqlite3'
  gem 'pry'
  gem 'pry-nav'
  gem 'thin'
  gem "better_errors"
  gem "binding_of_caller"
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end
+3
source share
2 answers

I believe that the irb configuration file does not load in rails consoleif the file is wrong. Run ruby ~/.irbrcto make sure it evaluates without complaint. Alternatively, you can verify that your console is even looking for your irbrc by running $LOAD_PATH.index{|s| s.include?('irbrc')}in your console.

+1
source

Pry. .pryrc.

0

All Articles