Created
February 18, 2014 10:33
-
-
Save olistik/9068351 to your computer and use it in GitHub Desktop.
Rails.logger is nil when invoking rake tasks [Ruby: 2.1.0p0, Rails: 4.0.2]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :foo do | |
if Rails.logger.nil? | |
puts "WAT" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ಠ_ಠ rails -v | |
Rails 4.0.2 | |
ಠ_ಠ ruby -v | |
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0] | |
ಠ_ಠ rails new mytest | |
.... | |
Your bundle is complete! | |
Use `bundle show [gemname]` to see where a bundled gem is installed. | |
ಠ_ಠ cd mytest/ | |
ಠ_ಠ cat lib/tasks/mytask.rake | |
task :foo do | |
if Rails.logger.nil? | |
puts "WAT" | |
end | |
end | |
ಠ_ಠ rake foo | |
WAT | |
ಠ_ಠ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This ML reply helped me understand that I was forgetting to require the
:environment
task.