sasikkumar
sasikkumar

Reputation: 216

Command to create a rake task with some folder

 rails g task folder1/namespace1 task1

Above command will create the task1.rake inside lib/tasks/task1.rake

But, I need to keep my task1.rake inside lib/tasks/folder1/task1.rake

Upvotes: 1

Views: 654

Answers (1)

Andreas Lyngstad
Andreas Lyngstad

Reputation: 4927

The rails g task generator does not work this way.

Here are the code for the TaskGenerator class

module Rails
  module Generators
    class TaskGenerator < NamedBase # :nodoc:
      argument :actions, type: :array, default: [], banner: "action action"

      def create_task_files
        template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
      end

    end
  end
end

As you see the lib/tasks path is hardcoded and you can not pass in options to alter the path.

I think this might be a great addition to the TaskGenerator class.

The answer to your question is that you have to make the folders manually.

Upvotes: 2

Related Questions