rake

How do I find the source file for a rake task?

落爺英雄遲暮 提交于 2019-12-20 09:21:37
问题 I know you can view all possible rake tasks by typing rake -T But I need to know what exactly a task does. From the output, how can I find a source file that actually has the task? For example, I'm trying to find the source for the db:schema:dump task. 回答1: Despite what others have said, you can programmatically get the source location of rake tasks in a rails application. To do this, just run something like the following in your code or from a console: # load all the tasks associated with

Is it possible to make an interactive Rake task?

我们两清 提交于 2019-12-20 08:56:23
问题 I want to run a Rake task that asks the user for input. I know that I can supply input on the command line, but I want to ask the user if they are sure they want to proceed with a particular action in case they mistyped one of the values supplied to the Rake task. 回答1: Something like this might work task :action do STDOUT.puts "I'm acting!" end task :check do STDOUT.puts "Are you sure? (y/n)" input = STDIN.gets.strip if input == 'y' Rake::Task["action"].reenable Rake::Task["action"].invoke

What exactly is Rake?

一个人想着一个人 提交于 2019-12-20 08:15:33
问题 In simple terms, what does Rake do? What purposes does it have? I understand it's a build tool but I'm looking a bit more detail. (For a simpleton.) 回答1: Try Martin Fowler's article on Rake for more information: http://martinfowler.com/articles/rake.html His pre-amble is: Rake is a build language, similar in purpose to make and ant. Like make and ant it's a Domain Specific Language, unlike those two it's an internal DSL programmed in the Ruby language. In this article I introduce rake and

puts vs logger in rails rake tasks

对着背影说爱祢 提交于 2019-12-20 08:12:23
问题 In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production. However if I say Rails.logger.info then in development mode I see nothing on console. I need to go to log file and tail that. I would ideally like to use Rails.logger.info and in development mode inside the rake task, the output from logger should also be sent to console. Is there a way to achieve that? 回答1: Put this in application.rb , or

puts vs logger in rails rake tasks

僤鯓⒐⒋嵵緔 提交于 2019-12-20 08:12:14
问题 In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production. However if I say Rails.logger.info then in development mode I see nothing on console. I need to go to log file and tail that. I would ideally like to use Rails.logger.info and in development mode inside the rake task, the output from logger should also be sent to console. Is there a way to achieve that? 回答1: Put this in application.rb , or

Heroku rake db:migrate does not create tables (Rails 5)

不问归期 提交于 2019-12-20 05:42:06
问题 I have a Rails 5 app and I wanted to destroy and rebuild my live database (site not launched yet). So I followed the steps that should've worked (they used to work in the past): heroku pg:reset HEROKU_POSTGRESQL_HEROKUCOLOR_URL --confirm {app_name} heroku run rake db:migrate heroku run rake db:seed Steps 1 & 2 complete successfully and step 3 fails with the error ('adminsettings' is one of my tables): Running rake db:seed on {app_name}... starting, run.7198 (Hobby) Running rake db:seed on

Heroku rake db:migrate does not create tables (Rails 5)

浪尽此生 提交于 2019-12-20 05:41:40
问题 I have a Rails 5 app and I wanted to destroy and rebuild my live database (site not launched yet). So I followed the steps that should've worked (they used to work in the past): heroku pg:reset HEROKU_POSTGRESQL_HEROKUCOLOR_URL --confirm {app_name} heroku run rake db:migrate heroku run rake db:seed Steps 1 & 2 complete successfully and step 3 fails with the error ('adminsettings' is one of my tables): Running rake db:seed on {app_name}... starting, run.7198 (Hobby) Running rake db:seed on

Rake tasks inside gem not being found

久未见 提交于 2019-12-20 04:56:41
问题 I have implemented what edebill suggested in his answer to this question. If I point to the gem in the usual way, with it installed in my environment gem 'activerecord_datawarehouse' rake -T does not show my rake tasks, but if I point directly to the gem source code, like gem 'activerecord_datawarehouse', :path => "/home/acras/code/activerecord_datawarehouse" It shows and rake tasks work perfectly. What could I be missing here? I did double checked and the installed gem is the same that I

Rake db:migrate error “don't know how to build task”

守給你的承諾、 提交于 2019-12-20 02:44:19
问题 I've got a table where I used integer on a field which needs decimal places, so I'm trying to create a migration which changes the field type from integer to float/real. My database is sqllite3 and I'm using rails3. I ran rails generate migration ChangeMeasureColumnOnIngredients to create the initial migration files, then updated the class to class ChangeMeasureColumnOnIngredients < ActiveRecord::Migration def self.up change_column :ingredients, :measure, :real end I ran rake db:migrate and

Keyword Extraction in Python_RAKE

流过昼夜 提交于 2019-12-19 11:53:32
问题 I am a novice user and puzzled over the following otherwise simple "loop" problem. I have a local dir with x number of files (about 500 .txt files). I would like to extract the corresponding keywords from each unique file using RAKE for Python. I've reviewed the documentation for RAKE; however, the suggested code in the tutorial gets keywords for a single document. Can someone please explain to me how to loop over an X number of files stored in my local dir. Here's the code from the tutorial