Ruby on Rails: Rake: rake stats didn't add my field to the correct value?
Date : March 29 2020, 07:55 AM
Hope that helps You're adding something called "Factories specs" (plural) to the STATS_DIRECTORIES array, but you call it "Factory specs" (singular) when you add it to TEST_TYPES array -- so when rake:stat hits your test/factories folder, it looks for "Factories specs" in TEST_TYPES, doesn't find it, and assumes it's code, not tests. You need to call it the same thing in both places: ::STATS_DIRECTORIES << %w(Factory\ specs test/factories) if File.exist?('test/factories')
::CodeStatistics::TEST_TYPES << "Factory specs" if File.exist?('test/factories')
|
calling a class method from scheduler.rake in ruby
Date : March 29 2020, 07:55 AM
will be helpful for those in need When you invoke Rake, you can pass the --trace flag to it. This should give you a backtrace, which I suspect is going to tell you the error is on the line not_flag = all_Active_Games > 0, because all_Active_Games is an ActiveRecord relation, but you're trying to compare it to the integer 0. Bascially, you have a type error. In a static language, this wouldn't even compile. It would also be good to also fix your indentation, choose more descriptive variable names (x -> game)
|
In Ruby on Rails rake task is calling a function from another rake file
Date : March 29 2020, 07:55 AM
seems to work fine As you can see, I've defined a function inside a rake file. No problem, that works fine. Problem is, when I declare def get_user_input in another rake file. In that case the function gets called from another .rake file Can you suggest anything? . , Moved the functions into a module and the problem gone. namespace :backtest do
Module MY
def self.get_user_input
if ENV['date_from'].present? && ENV['date_until'].present?
# get input...
else
abort 'Sample usage: blah blah...'
end
end
end
desc "Start backtest"
task :start => :environment do
My.get_user_input
# rest of the code...
end
end
|
When do I have to 'require' a Ruby class in my Rake task?
Date : March 29 2020, 07:55 AM
hop of those help? Net::HTTP is part of the Ruby Standard Library, which is distributed with Ruby itself (not Rails). To use any of the standard libraries you must require them first.
|
Ruby class expects class variable but only in Rake task
Tag : ruby , By : abuiles
Date : March 29 2020, 07:55 AM
it should still fix some issue When you see errors like "uninitialized constant" popping up and you're sure you've defined that constant in a file somewhere, make sure you're loading that code in before the method with the error runs. It looks like in this case config/environment wasn't loaded before DB was referenced, so it can't complete.
|