Questions tagged [rake-task]

Task is the basic unit of work in a Rakefile.

Tasks have associated actions (possibly more than one) and a list of prerequisites. When invoked, a task will first ensure that all of its prerequisites have an opportunity to run and then it will execute its own actions.

Tasks are not usually created directly using the new method, but rather use the file and task convenience methods.

689 questions
2
votes
1 answer

How can I require a gem inside a rake task that isn't in gemfile?

I'm trying to use a gem in a rake task, but I don't want to include it in the dev build. So not in the development part of the Gemfile. I don't want to include it in the Gemfile, because it's slow to install, and on the M2 Mac it doesn't always…
baash05
  • 4,394
  • 11
  • 59
  • 97
2
votes
0 answers

Rails 6 API deployment error on Railway - rake assets:precompile

I am trying to deploy my Rails 6 API app on Railway and keep getting this error: #18 [stage-0 14/14] RUN bundle exec rake assets:precompile #18 sha256:20d51ba84b3edc1879a0fe36e13a5cfe583beb59329a77a09bdbd9289c2403d7 #18 4.000 rake aborted! #18…
Zio-4
  • 189
  • 2
  • 12
2
votes
2 answers

How do you write a task to run tests in Rails 3?

I would like to write rake tasks to customize tests. For example, to run unit tests, I created a file with the following code and saved it as lib/tasks/test.rake: task :do_unit_tests do cd #{Rails.root} rake test:units end Running rake…
B Seven
  • 44,484
  • 66
  • 240
  • 385
2
votes
2 answers

Why we use the t as an arguments in rake task

namespace :git do desc "let's you clone a git repo by passing username and repo" task :clone, :user, :repo do |t, args| user = args[:user] repo = args[:repo] if system "git clone git@github.com:#{user}/#{repo}.git" puts…
Aaquib Jawed
  • 485
  • 4
  • 11
2
votes
0 answers

How to override the rake input prompt for automation?

I have been trying rake app:update:bin[a], rake app:update:bin\[a\], and others. I'd really like to figure this out if it can be. $ bundle exec rake app:update:bin exist bin conflict bin/rails Overwrite /home/me/coinship/bin/rails?…
listenlight
  • 654
  • 1
  • 12
  • 27
2
votes
0 answers

How could I have a Ruby Gem generate Rails db migrations?

I want to create a Ruby Gem to integrate specific functionality into my Rails app or any other Rails app that could use this functionality. The functionality will require its own database tables. How could I have a Ruby Gem generate the require…
ThriceGood
  • 1,633
  • 3
  • 25
  • 43
2
votes
1 answer

Why Rails 4.2 app create log files with root permissions when deploy it on Ubuntu server using Ansible during running rake db:migrate task

Scope of problem Rails 4.2.11 Ansible 2.1.1.0 Ubuntu 14 Ubuntu user: deploy I have Rails app which I deploy to Ubuntu server by Ansible script. I have problem of understanding why Rails app create log files with root permissions when Ansible…
2
votes
1 answer

Whenever gem to trigger Rails' ActiveJob vs rake task to run regularly scheduled task | Rails 5

I'm working on a Rails 5.2 project that requires a scheduled asynchronous task to run nightly. I've been looking at the differences between using the whenever gem to trigger an ActiveJob job, and using whenever to trigger an old-style rake task…
simonlehmann
  • 852
  • 1
  • 10
  • 27
2
votes
1 answer

How to import images from CSV and attach to model with ActiveStorage?

I'm trying to import users avatar from a CSV and attach to the users with ActiveStorage. I've created a rake task for this, but it's not working (and do not throws any error). In my CSV there are only 2 fields: email and avatar (avatar is the url…
deikka
  • 23
  • 1
  • 3
2
votes
0 answers

Why are DB tasks missing from rake?

When I run bundle exec rake db:setup I get an error saying that rake doesn't know how to build that task. I then run bundle exec rake -T and see that db tasks are missing (all output below). How can I access the db tasks? --application.rb-- require…
Ramy
  • 20,541
  • 41
  • 103
  • 153
2
votes
2 answers

Command to display all descriptions of rakefile tasks?

I know in Ant / Nant you can pass an argument like -projecthelp to get a list of avaialbe targets with descriptions. Is there a similar command-line argument for doing this with a rakefile's tasks? Also is there a way to generate documentation…
leeand00
  • 25,510
  • 39
  • 140
  • 297
2
votes
1 answer

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

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",…
JimmyC003
  • 17
  • 3
2
votes
1 answer

Rake Task and Namespaces

Is it a good idea to put rake tasks with different namespaces in different folders under task, also if there's only one file with a different namespace what should be done?
rails_newbie
  • 108
  • 1
  • 12
2
votes
0 answers

How to invoke migration in rake task in Rails5

In Rails 5, I am no longer able to use a rake task that migrates files in a different directory. I get the error ActiveRecord::UnknownMigrationVersionError: No migration with version number 20180209214145. Any idea how I could do this in Rails 5? …
Julie
  • 1,941
  • 3
  • 17
  • 30
2
votes
1 answer

Run rubocop installed from another directory

I have a wrapper directory which wrap my rails application: wrapper |____ Rakefile |____ my_task.rake |____ rails_app/ In my_task.rake I want to run bundle exec rubocop for rails_app (I have installed Rubocop for the app)`. Even tho I have…