From: "Paul D. Kraus" Date: 2006-05-27T15:00:03+09:00 Subject: Rails - Hashes ------=_Part_22829_15590040.1148709599803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I am trying to iterate over a hash but it only displays '#' for my key. I know this is not the case because it outputs the correct number of lines based on how many keys I have. If it were trully '#' it would only print on= e line. Here is the code that is producing the output... <% @payment.batch.each do|key,value| %>
  • <%=3Dkey%> -> <%=3Dvalue%>
  • <% end %> here is my output ... - # -> 1 - # -> 1 Here is the code that builds the hash... Controller... def add_invoice @payment =3D find_payment @invoice =3D Invoice.find(params[:id]) @payment.add_invoice(@invoice) end def find_payment session[:payment] ||=3D Payment.new end and the class.... class Payment include Reloadable attr_reader :batch def initialize @batch =3D {} end def add_invoice(invoice) unless @batch[invoice] @batch[invoice] =3D 1 end end end TIA, Paul ------=_Part_22829_15590040.1148709599803--