ruby - RAILS error NET::HTTP.post_form “private method `methods' called for #<Net::HTTP url open=false>” -
i want send require other url using net::http method post_form , rescue of backtrace returns error:
private method
methods' called #<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:inpost_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:inexport!'", "/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:insend_balance!'", "/home/duglas/sgc/lib/tasks/send_balance_control.rake:5:in
block (3 levels) in '", "/home/duglas/.rvm/gems/ruby-2.1.0@sgc/gems/activerecord-4.0.5/lib/active_record/relation/delegation.rb:13:ineach'", "/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:inblock (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:inblock 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:inexecute'", "/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:inmon_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:ininvoke'", "/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:inblock (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:inblock 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:intop_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:instandard_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 `'"]
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
my rake:
namespace :send_balance_control desc 'send balance of actives associate lines' task(generate: :environment) associateline.voice_lines.active.each |associate_line| external::export::hawk::balance.send_balance!(associate_line) end end end
can me urgently? lot
edit
balance
module external module export module hawk # essa classe é responsável por enviar o novo saldo associado para o hawk. class balance def self.send_balance!(*attr) new(*attr).send_balance! end # @params [associateline] associateline # associate_line [associateline]: associate line que será enviado o saldo def initialize(associate_line, options = {}) @associate_line = associate_line @export_balance = options.delete(:export_balance) { external::connection::export::hawk } @calculate_repository = options.delete(:calculate_repository) { external::export::hawk::calculatedatatosend } end def send_balance! # método será refeito de acordo com o brunno henrique, gerente de t.i. # pegar tarifa local pelo nome # 10:10 31/03/2014 number = associate_line.number.to_s minutes_balance = calculate_repository.calculate_minutes_balance(associate_line).to_s cash_balance = calculate_repository.calculate_cash_balance(associate_line).to_s hash = { number: number, minutes_balance: minutes_balance, cash_balance: cash_balance } export_balance.export!(hash: hash, send_method: hawkmethod::define_balance) end private attr_reader :associate_line, :export_balance, :calculate_repository end end end end
you added attr_reader under private . remove private:
class balance ..... attr_reader :associate_line, :export_balance, :calculate_repository class hawk .... attr_reader :settings, :send_method, :uri, :net_http, :manager_repository
i think that's problem .
Comments
Post a Comment