ruby - Rails console/rake detect in initializer. defined?(Rails::Console) does not working -
ruby - Rails console/rake detect in initializer. defined?(Rails::Console) does not working -
i have initializer in rails app don't want started rails console or rake task.
i set code initializer:
puts "start" if defined?(rails::console) puts "console" elsif file.basename($0) == "rake" puts "rake" end puts "end"
when run 'rails console' this:
$ rails console start end loading development environment (rails 4.2.0.beta2) [1] pry(main)>
but within console:
[1] pry(main)> defined?(rails::console) => "constant"
however, works rake:
$ bundle exec rake routes start rake end
why works within console, doesn't in initializer? or there improve way determine console/rake within initializer?
ruby-on-rails ruby ruby-on-rails-4 pry
Comments
Post a Comment