What is rake and how it is used in rails?
Ruby on-RailsRakeRuby on-Rails Problem Overview
What is rake and how it is used in Ruby on Rails?
Ruby on-Rails Solutions
Solution 1 - Ruby on-Rails
Rake is a "software task management tool", similar to Make, etc. in other systems.
See: http://guides.rubyonrails.org/command_line.html#rake
> Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'make', and uses a 'Rakefile' and .rake files to build up a list of tasks. In Rails, Rake is used for common administration tasks, especially sophisticated ones that build off of each other. > > You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks. Each task has a description, and should help you find the thing you need.
It is most often used for administration level tasks that can be scripted. The benefit to using Rake over Make or similar, is that it is a Ruby tool and can interface with your RoR app natively, so Models, data constraints and business rules are all available for use.
Rails comes with a set of predefined Rake tasks that allow you to perform database migrations, generate Rails scaffold files, etc.
Solution 2 - Ruby on-Rails
Rake utility allows you to create a job/task which uses rails environment. So say, you want to count the votes a user has given to an article and save it somewhere. You write a rake job, in which you can use Rails models and other helpers and get it done without going away from Rails.