rake-task

why rake tasks are not executing using and operator?

若如初见. 提交于 2021-01-29 09:21:33
问题 I have a rake task : task :kill_process do system %q(ps -ef | awk '{if($8~"java" || $8~"glassfish" || $8~"ruby" || $8~"god" || $8~"couch"){printf("Killing : %s \n",$2);{system("kill -9 "$2)};}}') end This is basically killing processes. And this task is a part of another rake task : desc "stop the entire system" task :stop => [...., :kill_process] There's another task: desc "start the entire system" task :start => [....] When I am doing rake stop && rake start stop task is executed

How to execute linux command from rakefile?

依然范特西╮ 提交于 2021-01-28 21:29:31
问题 I have the following command: ps -ef | awk '{if( $8~"java" || $8~"ruby" || $8~"god"){printf("Killing : %s \n",$2);{system("kill -9 "$2)};}};' How do i excute this linux command from rakeFile. I tried: task :kill_process do `ps -ef | awk '{if( $8~"java" || $8~"ruby" || $8~"god"){printf("Killing : %s \n",$2);{system("kill -9 "$2)};}};'` end But on executing it's giving error: awk: cmd. line:1: {if( $8~"java" || $8~"glassfish" || $8~"ruby" || $8~"god" || $8~"couch"){printf("Killing : %s awk: cmd

rake how to fix undefined local variable or method error?

♀尐吖头ヾ 提交于 2020-01-25 19:16:46
问题 i have a rake task as follows- desc 'send fetch request' task send_fetch_request: :environment do   FacebookCrawl.new.process end Yesterday this task working, but I don't know why it is not working today. I am trying to execute this with the below command- rake send_fetch_request Class details: class FacebookCrawl def initialize fb_config = YAML.load_file(Rails.root.join("config/facebook_catalog.yml")) @access_token = fb_config["facebook"]["access_token"] @product_feed_ids = fb_config[

Rails, Rake aborted! undefined method 'active_record'

人走茶凉 提交于 2020-01-15 11:46:06
问题 I'm sure I miss some basic thing. I had a correctly working app in dev environment. Than I had some modifications that I cant correctly explain (with the migrations and tried to insert seed_dump gem). Now every rake command drops an error: C:\Programozas\Rails Apps\sorsveto>rake about rake aborted! undefined method `active_record' for #<Rails::Application::Configuration:0x3e482 98> Tasks: TOP => about => environment (See full trace by running task with --trace) or C:\Programozas\Rails Apps

Rails, Rake aborted! undefined method 'active_record'

淺唱寂寞╮ 提交于 2020-01-15 11:46:03
问题 I'm sure I miss some basic thing. I had a correctly working app in dev environment. Than I had some modifications that I cant correctly explain (with the migrations and tried to insert seed_dump gem). Now every rake command drops an error: C:\Programozas\Rails Apps\sorsveto>rake about rake aborted! undefined method `active_record' for #<Rails::Application::Configuration:0x3e482 98> Tasks: TOP => about => environment (See full trace by running task with --trace) or C:\Programozas\Rails Apps

How to pick random element from array without repeating in Ruby?

…衆ロ難τιáo~ 提交于 2020-01-15 03:24:13
问题 I am new to coding and am trying to learn Ruby. I am working in a Rake. What should I use to ensure that the random selection never repeats the same response back to back? array = ["1", "2", "3", "4", "5"] task :array do array = ["1", "2", "3", "4", "5"] ap(array.sample) end 回答1: With array.shuffle.each{|x|} you can reorder the array, then traverse the new order, pulling items in a random order without repeating them. 来源: https://stackoverflow.com/questions/51162191/how-to-pick-random-element

rake db:migrate is being aborted due to rake version difference [duplicate]

不想你离开。 提交于 2020-01-10 19:26:46
问题 This question already has answers here : You have already activated X, but your Gemfile requires Y (6 answers) Closed 5 years ago . I am getting the error rake db:migrate --trace rake aborted! You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this. /Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup' /Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler

Rails - Update attributes using rake task. Need help troubleshooting model method code

心已入冬 提交于 2020-01-06 18:08:22
问题 I am trying to use a rake task that will run every night (using Heroku Scheduler) and update some attributes if some certain criteria is met. A little logic about the application: The application allows users to "take the challenge" and read a book a week over the course of a year. It's pretty simple: users sign up, create the first book that they will read for their first week, then can enter what they're going to read next week. After they've "queued" up next week's book, that form is then

How to trigger a rake task using whenever in Rails

柔情痞子 提交于 2020-01-03 05:14:15
问题 I am writing a Rake task. I want to trigger it every last sunday of every month at 11 pm. How can I schedule this using the Whenever gem in Ruby on Rails? I have my rake task in the following location: app/lib/tasks/my_task.rake task :create_entries => :environment do puts "Hello" end 回答1: I don't think there's a rule for "last x day of the month" but you can always put an extra if test inside the block: every :sunday, :at => '11pm' do #if the month is different a week from now, we must be in

How to trigger a rake task using whenever in Rails

给你一囗甜甜゛ 提交于 2020-01-03 05:14:10
问题 I am writing a Rake task. I want to trigger it every last sunday of every month at 11 pm. How can I schedule this using the Whenever gem in Ruby on Rails? I have my rake task in the following location: app/lib/tasks/my_task.rake task :create_entries => :environment do puts "Hello" end 回答1: I don't think there's a rule for "last x day of the month" but you can always put an extra if test inside the block: every :sunday, :at => '11pm' do #if the month is different a week from now, we must be in