NoMethodError: undefined method 'send_data' for CloneDatabase: Class

0

Rails does not find method send_data

clone_database.rb    

require 'zip'

class CloneDatabase < ApplicationController
  def self.make_clone
    zip_data = 'a'.to_json
    send_data zip_data, type: 'application/zip', filename: 'Topic.zip'
  end
end

test.rake

  namespace :my_namespace do
      desc 'Clone database'
        task clone_database: :environment do
          CloneDatabase.make_clone
        end
    end
    
asked by anonymous 12.12.2016 / 18:03

1 answer

0

Hello @Ruan,

I think you're not finding why send_data is an instance method, right? and you're wanting to use it within a class method.

Try to remove self from your make_clone method and in your task try something like:

clone_database = CloneDatabase.new
clone_database.response = ActionDispatch::Response.new
clone_database.make_clone
    
12.12.2016 / 18:11