2010-10-17 33 views
71

Tại sao một số tác vụ cào không được liệt kê bởi rake -T? Giống như db:migrate:reset? Tôi có thể thực hiện nó mà không có vấn đề gì, nhưng tại sao nó không được liệt kê ở đó? Có cách nào để có được danh sách đầy đủ các nhiệm vụ cào không?Tại sao rake db: di chuyển: đặt lại không được liệt kê trong rake -T?

 
% rake -T 
(in /home/zeus/projects/my_project) 
rake about    # List versions of all Rails frameworks and the environment 
rake db:create   # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config) 
rake db:drop   # Drops the database for the current Rails.env (use db:drop:all to drop all databases) 
rake db:fixtures:load # Load fixtures into the current environment's database. 
rake db:migrate   # Migrate the database (options: VERSION=x, VERBOSE=false). 
rake db:migrate:status # Display status of migrations 
rake db:rollback  # Rolls the schema back to the previous version (specify steps w/ STEP=n). 
rake db:schema:dump  # Create a db/schema.rb file that can be portably used against any DB supported by AR 
rake db:schema:load  # Load a schema.rb file into the database 
rake db:seed   # Load the seed data from db/seeds.rb 
rake db:setup   # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first) 
rake db:structure:dump # Dump the database structure to an SQL file 
rake db:version   # Retrieves the current schema version number 
rake doc:app   # Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title") 
rake erd    # Generate an Entity-Relationship Diagram based on your models 
rake log:clear   # Truncates all *.log files in log/ to zero bytes 
rake middleware   # Prints out your Rack middleware stack 
rake notes    # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus) 
rake notes:custom  # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM 
rake rails:template  # Applies the template supplied by LOCATION=/path/to/template 
rake rails:update  # Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs) 
rake routes    # Print out all defined routes in match order, with names. 
rake secret    # Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions). 
rake spec    # Run all specs in spec directory (excluding plugin specs) 
rake spec:acceptance # Run the code examples in spec/acceptance 
rake spec:controllers # Run the code examples in spec/controllers 
rake spec:helpers  # Run the code examples in spec/helpers 
rake spec:lib   # Run the code examples in spec/lib 
rake spec:mailers  # Run the code examples in spec/mailers 
rake spec:models  # Run the code examples in spec/models 
rake spec:rcov   # Run all specs with rcov 
rake spec:requests  # Run the code examples in spec/requests 
rake spec:routing  # Run the code examples in spec/routing 
rake spec:views   # Run the code examples in spec/views 
rake stats    # Report code statistics (KLOCs, etc) from the application 
rake test    # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins) 
rake test:recent  # Run tests for recenttest:prepare/Test recent changes 
rake test:uncommitted # Run tests for uncommittedtest:prepare/Test changes since last checkin (only Subversion and Git) 
rake time:zones:all  # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6 
rake tmp:clear   # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear) 
rake tmp:create   # Creates tmp directories for sessions, cache, sockets, and pids 
+0

khi tôi chạy rake -T, nó hiển thị ... bạn đang chạy đường ray nào? – thatmiddleway

+0

Tôi sử dụng đường ray 3.0.1. Trên hai hệ thống khác nhau với hai dự án khác nhau. Nó không hiển thị trên cả hai hệ thống (xem đầu ra đầy đủ trong bài chỉnh sửa). – Zardoz

+0

Kiểm tra câu trả lời cập nhật của tôi. –

Trả lời

79

Tác vụ không có mô tả sẽ không hiển thị.

EDIT: Có vẻ như DHH đã xóa mô tả khỏi Rails 3 để thực hiện một số tác vụ 'giảm tiếng ồn'. rake db: setup có một lưu ý về db: reset mặc dù.

http://github.com/rails/rails/commit/983815632cc1d316c7c803a47be28f1abe6698fb

+33

Là một người học Rails, tôi đã lãng phí rất nhiều thời gian để tìm tài liệu rõ ràng, tốt cho các công việc cào liên quan đến di chuyển db. –

39

Bạn có thể sử dụng rake -P | grep rake để hiển thị tên của tất cả các nhiệm vụ Rake.

+0

Đây chính xác là những gì tôi cần. Tôi đã thêm nó vào bash_profile của tôi với bí danh "raket" như sau: # Hiển thị tất cả các tác vụ cào có sẵn, bao gồm các tác vụ không có mô tả. bí danh raket = "rake -P | grep rake" Hoạt động tuyệt vời. Cảm ơn! –

61

Bạn cũng có thể sử dụng rake db -T -A để hiển thị tất cả công việc, thậm chí là các công việc chưa được xử lý. Để tham khảo, các công tắc này đang thực hiện các thao tác sau:

-T, --tasks [PATTERN] Display the tasks (matching optional PATTERN) with 
         descriptions, then exit. 
-A, --all    Show all tasks, even uncommented ones (in combination 
         with -T or -D) 
+8

Đây phải là câu trả lời được chấp nhận. –

+3

Lưu ý rằng tùy chọn -A (hoặc --all) đã được thêm vào trong Rake 10. – slothbear

+0

'rake -T -A' hiển thị tất cả các nhiệm vụ. 'rake -T db -A' hiển thị tất cả các tác vụ chứa' db' trong tên tác vụ (vị trí lưu ý của 'db' ** sau **' -T'). –

1

Đối với người dùng windows, bạn làm điều này rake-P | tìm "rake"

7

Theo dõi câu trả lời của Thomas Obermüller, vì cờ -T có một đối số vị trí, để chỉ nhận nhiệm vụ không gian tên 'db' (ít nhất là với rake 10.0.3), bạn cần làm : rake -T db -A

Các vấn đề liên quan