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
2 answers

Is it possible to look up a route in Rails by a given url?

Sometimes when customizing a large preexisting Rails platform (e.g. Spree) it would be nice to be able to look up routes by url. Something like: rake routes URL=/preexisting/url This obviously doesn't work but is there something like this available…
Ryan Linton
  • 1,285
  • 1
  • 14
  • 20
2
votes
3 answers

Adding sample data to database using rake for a rails engine

I am trying out Rails engines by creating a classifieds engine where users can view/post/reply to classifieds. The main application contains code for user authentication and profiles while there is an engine which I have created which will deal…
sv_in
  • 13,929
  • 9
  • 34
  • 55
2
votes
1 answer

Rake does not recognize rules with multiple extensions

I generate PDFs from Markdown files using Rake. If a Markdown file is filename.md, I like the PDF to be filename.md.pdf not filename.pdf, so that autocompletion works the way I like and so that it's clear what the source of the PDF file is. I have…
Lincoln Mullen
  • 6,257
  • 4
  • 27
  • 30
2
votes
2 answers

Unable to over-write devise routes

I am using devise and I want to customize its urls: users/sign_in --> account/login users/sign_up --> account/register users/edit --> account/profile ... Now my routes.rb looks like this: devise_scope :user do get '/account/login' =>…
Besi
  • 22,579
  • 24
  • 131
  • 223
2
votes
2 answers

Rails migration -- rake db:status says migration is down, but database is already migrated?

I have a local PSQL database setup and am having issues getting rake db:migrate to function properly. For instance, my database has already had its high_school column name changed to high_school_name, but rake db:migrate is failing, and the status…
trevorhinesley
  • 845
  • 1
  • 10
  • 36
2
votes
0 answers

Heroku: Error R99 (Platform error) when running `heroku run rake db:migrate`

I am running a Heroku app under multiple environments as described here. I am able to run under my original single environment fine, but when I push to one of the others and run heroku run rake db:migrate --remote REMOTE_NAME I get an error of the…
user456584
  • 86,427
  • 15
  • 75
  • 107
2
votes
1 answer

How to publish my ruby gem to my own repository?

I have written a ruby gem and I would like to have a rake task for publishing the gem to my own GemInABox repository : http://my-gem-repo.com. What is the simplest way of achieving this goal? Also, I would like to prevent the default publishing to…
viebel
  • 19,372
  • 10
  • 49
  • 83
2
votes
1 answer

ruby rake guard task

Ruby noob - I need to have guard running in my rake tasks but I can't find a way to have it run in the background. It needs to run 2nd last, therefore having the guard > shell waiting for commands is preventing the final task from running, so…
Daithí
  • 4,717
  • 5
  • 26
  • 35
2
votes
0 answers

Rake migrate Error - database doesn't exist

I have a padrino project that uses data mapper and postgres. When I run padrino rake dm:create it says that the database is created. However, when I run padrino rake dm:auto:migrate, I get the error - FATAL: database "dbname_development" does not…
MParker
  • 315
  • 2
  • 3
  • 10
2
votes
2 answers

Run all models tests using rake task

Trying to use a rake task to run only tests in the test/models directory. Using minitest. I have a rake task that will run all test require "rake/testtask" Rake::TestTask.new(:test => "db:test:prepare") do |t| t.libs << "test" …
hellion
  • 4,602
  • 6
  • 38
  • 77
2
votes
0 answers

ROR can't fine rake 10.0.4 despite being in vendor/cache

So this is annoying. When I put bundle exec rake db:migrate into terminal, the following error occurs: Could not find rake-10.0.4 in any of the sources Run `bundle install` to install missing gems. So I check with bundle show rakeand it's there…
user1337902
  • 236
  • 3
  • 11
2
votes
1 answer

Change a RDoc template for generating Rails app documentation

I have just added some documentation to my Rails 3.2.13 app. I can generate the documentation just fine (running RDoc 3.12.2) by using a rake task: #…
Christoffer Reijer
  • 1,925
  • 2
  • 21
  • 40
2
votes
2 answers

Rake (Ruby) catch error at end of build

I'm using Ruby and Rake to do our builds at the moment for .Net projects. I call a few commandline tools, such as NCover to check the coverage is high enough. When NCover returns and exit (fail) code though, Rake exits immediately stops. Is there a…
Bealer
  • 864
  • 9
  • 16
2
votes
1 answer

assets missing when launching/debugging Rails from RubyMine

I'm trying to test an opensource Ruby on Rails site (pophealth). I've got a VM running Ubuntu 12.10 and RubyMine. It took a while to get all of the gems working right but they are working well now. However, now all of the static assets that are…
Dan Csharpster
  • 2,662
  • 1
  • 26
  • 50
2
votes
1 answer

Getting error trying to use Jekyll rake command

I am trying to learn Jekyll and if I enter the following command rake post title="Hello World" I get the following error: rake post title="My First Post" /usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake'…
SJS
  • 5,607
  • 19
  • 78
  • 105