public
Description: /bin/zsh and loving it
Homepage: http://stephencelis.com/archive/2008/10/ez-does-it-gemdoc
Clone URL: git://github.com/stephencelis/dotfiles.git
dotfiles / railsrc
100644 28 lines (23 sloc) 0.572 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
RAILS_DIRNAME = File.basename(Dir.pwd)
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
  :PROMPT_I => "#{RAILS_DIRNAME}> ",
  :PROMPT_N => "#{RAILS_DIRNAME}> ",
  :PROMPT_S => "#{RAILS_DIRNAME}* ",
  :PROMPT_C => "#{RAILS_DIRNAME}? ",
  :RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
 
def change_log(stream)
  ActiveRecord::Base.logger = Logger.new(stream)
  ActiveRecord::Base.clear_active_connections!
end
 
def show_log
  change_log(STDOUT)
end
 
def hide_log
  change_log(nil)
end
 
def sql(query)
  ActiveRecord::Base.connection.select_all(query)
end