Now I want to run a task under a rails project. I want to catch a parameter when I run it.
If I use thor
> http://whatisthor.com , I can catch parameters but it seems can't access the rails' active record.
I want to run a task like:
bundle exec rails runner MyTask hello --params1 '1' --params2 '2'
I got errors:
ERROR: "rails_runner help" was called with arguments ["--params1", "1", "--params2", "2"]
Usage: "rails_runner help [COMMAND]"
Thor
is OK. After I try again. It can use Active Record
.
Then I can run the batch like this:
./bin/rails runner MyTask hello A --from B