Private method error when running NET :: HTTP.post_form with Rake

0

I'm trying to send a request using NET::HTTP.post_form , but it's returning this error:

Code:

module External
  module Connection
    module Export
      class Hawk
        require 'net/http'
        require 'uri'

        attr_accessor :hash

        def self.export!(*attr)
          new(*attr).export!
        end

        def initialize(options = {})
          self.hash = options.delete(:hash)
          @send_method = options.delete(:send_method)

          @uri = options.delete(:uri) { URI }
          @net_http = options.delete(:net_http) { Net::HTTP }
          @settings = options.delete(:settings) { ::Settings }
          @manager_repository = options.delete(:manager_repository) { ::Manager }
        end

        def export!
          begin
            manager = manager_repository.is_active.last
            self.hash[:token] = manager.token_importer

            url = uri.join manager.url_importer, send_method.to_s

            net_http.post_form(url, hash) if settings.connection_export
          rescue
            # TODO
          end
        end

        private

        attr_reader :settings, :send_method, :uri, :net_http, :manager_repository
      end
    end
  end
end

Error:

private method 'methods' called for #<Net::HTTP my_url open=false>
["/home/duglas/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:576:in 'start'",
"/home/duglas/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:507:in 'post_form'",
"/home/duglas/sgc/app/business/external/connection/export/hawk.rb:31:in 'export!'",
"/home/duglas/sgc/app/business/external/connection/export/hawk.rb:11:in 'export!'",
"/home/duglas/sgc/app/business/external/export/hawk/balance.rb:27:in 'send_balance!'",
"/home/duglas/sgc/app/business/external/export/hawk/balance.rb:7:in 'send_balance!'",
"/home/duglas/sgc/lib/tasks/send_balance_control.rake:5:in 'block (3 levels) in <top (required)>'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/activerecord-4.0.5/lib/active_record/relation/delegation.rb:13:in 'each'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/activerecord-4.0.5/lib/active_record/relation/delegation.rb:13:in 'each'",
"/home/duglas/sgc/lib/tasks/send_balance_control.rake:4:in 'block (2 levels) in <top (required)>'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:240:in 'call'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:240:in 'block in execute'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:235:in 'each'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:235:in 'execute'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:179:in 'block in invoke_with_call_chain'",
"/home/duglas/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in 'mon_synchronize'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:172:in 'invoke_with_call_chain'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/task.rb:165:in 'invoke'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:150:in 'invoke_task'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:106:in 'block (2 levels) in top_level'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:106:in 'each'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:106:in 'block in top_level'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:115:in 'run_with_threads'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:100:in 'top_level'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:78:in 'block in run'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:176:in 'standard_exception_handling'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/lib/rake/application.rb:75:in 'run'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/rake-10.3.2/bin/rake:33:in '<top (required)>'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/bin/rake:23:in 'load'",
"/home/duglas/.rvm/gems/ruby-2.1.0@sgc/bin/rake:23:in '<main>'"]

Rake:

namespace :send_balance_control do
  desc 'Send balance of actives associate lines'
  task(generate: :environment) do
    AssociateLine.voice_lines.active.each do |associate_line|
      External::Export::Hawk::Balance.send_balance!(associate_line)
    end
  end
end

Another thing: when I use rails c (console) and squeeze the code that is inside the rake works. But when I start rake it does not work.

    
asked by anonymous 27.06.2014 / 15:07

0 answers