Ruby-on-rails 什么是耙子以及它如何在导轨中使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18737696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is rake and how it is used in rails?
提问by Mothirajha
I have started my tutorials on Ruby on rails just a week ago I have got a doubt please guide me guys ....!
一周前我开始了关于 Ruby on rails 的教程我有疑问请指导我......!
What is rake and how it is used in rails?
什么是耙子以及它如何在导轨中使用?
回答by michaelward82
Rake is a "software task management tool", similar to Make, etc. in other systems.
Rake是一个“软件任务管理工具”,类似于其他系统中的Make等。
See: http://guides.rubyonrails.org/command_line.html#rake
请参阅: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.
Rake 是 Ruby Make,一个独立的 Ruby 实用程序,它取代了 Unix 实用程序“make”,并使用“Rakefile”和 .rake 文件来构建任务列表。在 Rails 中,Rake 用于常见的管理任务,尤其是相互构建的复杂任务。
您可以通过键入 rake --tasks 来获取可用的 Rake 任务列表,这通常取决于您的当前目录。每个任务都有一个描述,应该可以帮助你找到你需要的东西。
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.
它最常用于可以编写脚本的管理级任务。使用 Rake 而不是 Make 或类似工具的好处在于,它是一个 Ruby 工具,可以与您的 RoR 应用程序本地交互,因此模型、数据约束和业务规则都可以使用。
Rails comes with a set of predefined Rake tasks that allow you to perform database migrations, generate Rails scaffold files, etc.
Rails 带有一组预定义的 Rake 任务,允许您执行数据库迁移、生成 Rails 脚手架文件等。
回答by techvineet
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.
Rake 实用程序允许您创建使用 rails 环境的作业/任务。比如说,你想计算用户对一篇文章的投票并将其保存在某个地方。您编写了一个 rake 作业,您可以在其中使用 Rails 模型和其他帮助程序,并在不离开 Rails 的情况下完成它。

