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
quiet, doing now
– Ruan Nawe
the error has changed, that’s good
– Ruan Nawe
NoMethodError: undefined method
content_type=' for nil:Nilclass`– Ruan Nawe
@Ruannawe is complicated, as you are not doing a request ( which is the natural behavior for an action) some variables will not be set, which will take a lot of work to do this manually. What’s your goal with this? We can find an alternative solution better than calling an action like this.
– Luiz Carvalho
@Ruannawe edited my reply with a possible solution, manually uploaded the controller’s answer to try to avoid the error with content_type.
– Luiz Carvalho