ruby - Error "no implicit conversion of Symbol into Integer" with gem savon rails -


i using gem savon read xml, brought results correctly. when show in view fields of xml shows correctly, when want show 1 of these fields of error. "" put down code.

class code < activerecord::base    	attr_accessor :strdatainicial, :strdatafinal        def initialize(strdatainicial)          @strdatainicial = strdatainicial      end        def data          if response.success?              return document(response)          else              raise "error message"          end      end        private        def document(response)          data = response.to_hash[:ocupacao_por_segmento_response][:ocupacao_por_segmento_result][:ocupacao_por_segmento]          if data              data          else              nil          end        end        def response          client.call(              :ocupacao_por_segmento,              message: {                  strdatainicial: @strdatainicial,                  strdatafinal: "03/25/2015",                  blnconsiderareservasdayuse: true,                  strgrupo1: "s",                  strgrupo2: "s",                  exibevalorescontaavulsa: true,                  strpool: "s",                  hotelid: "1"              }          )      end        def client          savon.client(              wsdl: "http://172.31.1.3:1588/esolutionweb?singlewsdl",              endpoint: "http://172.31.1.3:1588/esolutionweb?singlewsdl",              ssl_verify_mode: :none          )      end    end
class codescontroller < applicationcontroller    	def index          @code = code.new(params[:strdatainicial])          @code = @code.data      end    end
<%= form_tag root_url, method: :get %>  <p>    <%= text_field_tag :strdatainicial, params[:strdatainicial] %>    <%= text_field_tag :strdatafinal, params[:strdatafinal] %>    <%= submit_tag "enviar" %>  </p>  <% end %>    <% if @code %>    <dl id ="zip_info">      <dt>diaria media:</dt>      <dd><%= @code[:diariamedia] %></dd>    </dl>  <% end %>

the @code instance variable (that might reverse engineered response.to_hash[:ocupacao_por_segmento_response][:ocupacao_por_segmento_result][:ocupacao_por_segmento] seems array.

it impossible suggest working solution without knowledge underlying data, suggest try:

<dd><%= @code.first[:diariamedia] %></dd> 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -