def task_execution
      begin
        require 'rake'

        Rails.application.load_tasks
        ::Rake::Task[params[:task]].execute
      rescue StandardError => e
        flash[:alert] = e.message
      else
        flash[:notice] = "Task: #{params[:task]} has completed"
      end

      redirect_to root_path
    end
def task_execution
      begin
        require 'rake'

        Rails.application.load_tasks
        ::Rake::Task[params[:task]].execute
      rescue StandardError => e
        flash[:alert] = e.message
      else
        flash[:notice] = "Task: #{params[:task]} has completed"
      end

      redirect_to root_path
    end
POST /task
 TODO: Move this to a separate controller e.g. `tasks_controller.rb`