console 1018 字节
Newer Older
1 2 3 4 5
#!/usr/local/bin/ruby

if ARGV[0]
  ENV['RAILS_ENV'] = ARGV[0]
  puts "Loading environment..."
6 7 8 9 10 11
  if RUBY_PLATFORM =~ /mswin32/
    irb_name = "irb.bat"
  else
    irb_name = 'irb'
  end
  exec "#{irb_name} -r config/environment.rb -r irb/completion --noinspect"
12 13 14 15
else
  puts <<-HELP

NAME
16
     console - interact with the domain model through a environment console (on IRB)
17 18

SYNOPSIS
19
     console [environment]
20 21 22 23 24 25 26 27 28

DESCRIPTION
     Starts an environment console using IRB that lets you manipulate and interrogate
     the domain model or even trigger controller actions. The database connection and
     configuration available to the web application is already setup.
     
     Tab completion is available to see classes and methods on individual objects.
     
EXAMPLE
29
     console production
30 31 32 33 34
     
     This will initialize the production environment (as setup in config/database.yml
     and config/environments/production.rb). You would now be ready to start requiring
     models using require_dependency.
HELP
35
end