Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the source code of Rake tasks in Rails 3?

Tags:

all:

I know how to show all the tasks by typing rake -T, and I know how to add my own tasks by add rake files under RAILS_ROOT/lib/tasks. But if I want to view the source code like rake db:migrate or rake doc:app to see how they work, where can I find those codes?

thank you all :)

eddie

like image 692
高見龍 Avatar asked Jul 03 '11 15:07

高見龍


People also ask

Where are rake tasks Rails?

rake extension and are placed in Rails. root/lib/tasks . You can create these custom rake tasks with the bin/rails generate task command. If your need to interact with your application models, perform database queries and so on, your task should depend on the environment task, which will load your application code.

How do I see list of rake tasks?

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.

Where is rake task defined?

In any Rails application you can see which rake tasks are available - either by running rake -AT (or rake --all --tasks) to see all tasks, or rake -T (or rake --tasks ) to see all tasks with descriptions.

What are rake tasks in Rails?

Rake is a popular task runner for Ruby and Rails applications. For example, Rails provides the predefined Rake tasks for creating databases, running migrations, and performing tests. You can also create custom tasks to automate specific actions - run code analysis tools, backup databases, and so on.


2 Answers

All rails internal rake tasks are in railties/lib/rails/tasks

like image 193
Damien MATHIEU Avatar answered Sep 22 '22 18:09

Damien MATHIEU


All rake tasks of database is in active record.

https://github.com/rails/rails/blob/f47b4236e089b07cb683ee9b7ff8b06111a0ec10/activerecord/lib/active_record/railties/databases.rake

like image 35
Ryan Lv Avatar answered Sep 22 '22 18:09

Ryan Lv