简体   繁体   中英

how to run this rake task with 2 args and environment in rails 4?

Here are the first few lines of my rake task:

 desc "Import National Data into DB\n Usage: 
 rake import_regional[/Users/am/0925/xyz.csv, some_market]"

 task :import_regional, [:file_path, :market] => [:environment] do |t, args|

 .......

Here is how Im trying to run this task on the command line:

 rake import_regional ["/Users/xyz.csv", "northeast"]

when I try this, I get this error

 rake aborted!
 Don't know how to build task 
 'import_regional[/Users/xyz.csv,'

I suspect it's the way in which you're running the task on the command-line; the [] doesn't have its Ruby meaning, there. Instead, maybe see if this works for you:

rake "import_regional[/Users/xyz.csv, northeast]"

This should still allow for spaces, etc. in :file_path , if required.

Peace, tiredpixel

Command line isn't a Ruby interpreter, it's mangling things before it gets to Rake.

Try this:

rake "import_regional['/Users/xyz.csv', 'northeast']"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM