I have this code in an initializer:
if $0 == 'irb' # ... end
It works fine with Rails 2.3 but in Rails 3 the value of $0 is 'script/rails' no matter if it was started with rails c or rails s. ARGV is an empty array. How can I detect if the application has been started with "rails c" or "rails console"?
You could try this perhaps
if defined?(Rails::Console) # in Rails Console else # Not in Rails Console end
1.4m articles
1.4m replys
5 comments
57.0k users