1. 新建一个 文件: script/test_hi.rb
# 运行方式: # # $ bundle exec ruby script/test_hi.rb # ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'production' require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'rails' require 'rubygems' puts 'hihihi' puts User.all
2. 运行: $ bundle exec ruby script/test_hi.rb