Questions tagged [rake]

Ruby build utility similar to make with build commands defined in pure Ruby.

Rake uses Rakefiles (cf. Makefiles) defined in pure Ruby, the build utility created by the late Jim Weirich. Rule patterns to synthesize implicit tasks are supported and developers can easily specify pre- and post-task dependency chains. Rake includes a library of pre-packaged tasks to make creating Rakefiles easier.

Rake uses Ruby's anonymous function blocks to define various tasks, allowing the use of Ruby syntax. It has a library of common tasks: for example, functions to do common file-manipulation tasks and a library to remove compiled files (the "clean" task). Like Make, Rake can also synthesize tasks based on patterns: for example, automatically building a file compilation task based on filename patterns. Rake is now part of the standard library from Ruby version 1.9 onward.

Sample Rake file

    namespace :pick do
      desc "Pick a random user as the winner"
      task :winner => :environment do
        puts "Winner: #{pick(User).name}"
      end

      desc "Pick a random product as the prize"
      task :prize => :environment do
        puts "Prize: #{pick(Product).name}"
      end

      desc "Pick a random prize and winner"
      task :all => [:prize, :winner]

      def pick(model_class)
        model_class.find(:first, :order => 'RAND()')
      end
    end

Useful links

Implementation specific tags

You can specify your question by adding the implementation you used as a tag.

4366 questions
2
votes
1 answer

uninitialized constant Rack::Massive (NameError)

i am trying to create a rake basic app first in a directory i created helloworld.ru with code class HelloRack def call(env) ["200",{"Content-Type" => "text/plain"}, "Hello World"] end end run HelloRack.new i run it with rackup helloworld.ru…
mathlearner
  • 7,509
  • 31
  • 126
  • 189
2
votes
4 answers

How to use FileLists as rake dependencies

I'm using rake to help compile Coffeescript for a Chrome extension I'm writing. My Rakefile looks like this: COFFEE = FileList['src/*.coffee'] JS = COFFEE.ext 'js' directory 'extension' rule '.js' => ['.coffee', 'extension'] do |t| `coffee -c -o…
Andy
  • 778
  • 5
  • 16
2
votes
1 answer

Rake database migrate failing with "undefined method `double`"

I've defined a scaffold with some of the sqlite columns having type double. When I run rake db:migrate, it gives the following error: undefined method `double' for # Is there another way to…
nevan king
  • 112,709
  • 45
  • 203
  • 241
2
votes
3 answers

Models not loaded when running migrations and rake tasks in staging environment

I am trying to run the following migration in staging with RAILS_ENV=staging bundle exec rake db:migrate --trace class UpdateDatabaseForPayments < ActiveRecord::Migration def change # Create the plans Plan.create(:name => "Student") …
Simon Thordal
  • 893
  • 10
  • 28
2
votes
1 answer

ruby net/ssh failing to execute rake commands remotely

Hi I'm trying to use the ruby net/ssh gem (2.0.24) to connect to a remote server and run a rake task. I can run other simple tasks using the script outlined below, but rake is failing. This is my code Net::SSH.start("myremote_server", 'ubuntu',…
user141146
  • 3,285
  • 7
  • 38
  • 54
2
votes
1 answer

Do Not Echo File Operations

I have a Ruby script that I'm running in PowerShell (via Rake) which contains a number of operations from FileUtils. (Things like cp, cp_r, etc.) It seems that anything within FileUtils has its command echoed to the screen when it's executed. …
David
  • 208,112
  • 36
  • 198
  • 279
2
votes
2 answers

Why can't TeamCity run this Rake build using Albacore?

I created a build script using Rake & Albacore which builds a solution and executes unit tests. I am trying to set it up in TeamCity. I am getting this error. Cannot start build runner: If you wan't to use bundler please install it at first. The…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
2
votes
3 answers

Bin deploy rake (and IronRuby)

I'm on a .NET project, and I would like to migrate build script from MsBuild to Rake. I don't want to force developers (or build agent machines) to have to install anything, I want it to be self contained. If possible I'd prefer to use IronRuby. Is…
Krzysztof Kozmic
  • 27,267
  • 12
  • 73
  • 115
2
votes
2 answers

How do I run a Rake task every time a file is saved in Visual Studio?

How do I run a rake script automatically every time I save a file in Visual Studio? I can create a batch file that wraps the command. And I'd like to trigger it on CTRL + S. But, Visual Studio 2012 doesn't have macros. JP Boodhoo has done it in many…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
2
votes
2 answers

Rails rake db:schema:dump against SQL Server database with multiple schemas

The situation I have is that we have multiple schemas on SQL Server that we need to be able to do schema:dump and migrations against. One schema is for our new Rails application, the other schema is for a legacy system that we have dependencies…
bigtunacan
  • 4,873
  • 8
  • 40
  • 73
2
votes
2 answers

Rails and Rake task - How to call a Rails method inside a custom class defined in a rake task file

I have the following code in "Rails Root"/lib/tasks/example.rake: task :example_task => :environment do e = Example.new e.example_method end class Example def example_method select_tag 'Example' end end When I call e.example_method in…
Miscreant
  • 6,626
  • 3
  • 22
  • 21
2
votes
1 answer

rake db:migrate error (Function 'inotify_init' not found)

I just got done setting up my rails environment on my old mac book and ran into this error. I've installed FFI and rb-inotify. I've also ran bundle install again. I've looked…
Foolish Chap
  • 765
  • 1
  • 5
  • 19
2
votes
2 answers

How to fix zsh: correct 'deploy' to '_deploy' [nyae]?

I am playing around with Octopress/github pages. When I type rake deploy, the terminal always outputs zsh: correct 'deploy' to '_deploy' [nyae]?. I enter n. What do I need to do in order not to display 'zsh: correct 'deploy' to '_deploy' [nyae]? '…
shin
  • 31,901
  • 69
  • 184
  • 271
2
votes
2 answers

rake-pipeline performance

We're using Rake::Pipeline::Middleware to serve a rake-pipeline project with Rack. It seems incredibly slow, like it's rebuilding everything whenever a file has changed. Are we doing something wrong? Is there something we can do to speed it up?
Jo Liss
  • 30,333
  • 19
  • 121
  • 170
2
votes
1 answer

Executing command rake:db:schema:dump

Im new with rails and Im trying to execute rake db:schema:dump, but Im having this problem. rake db:schema:dump --trace ** Invoke db:schema:dump (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config…
1 2 3
99
100