Each returns just last array

Felipe Pieretti Umpierre
Wed, 15 Feb 2012 01:58:10 -0000

Hello, I was testing a only string, and split it to get a array, I make
a .each, but when I put to insert, it just insert the last index.

emails_controller.rb

emails = params[ :email ][ :email ].split( ";" )
@e = emails

action
<%= @e %>

return : ["myemail-S8S1utOw9MsAvxtiuMwx3w@public.gmane.org,My Name",
"myemail-4cajJJ5tN1zQT0dZR+AlfA@public.gmane.org,My Name"]

emails_controller.rb

emails.each do |e|

      for_each_one = e.split( "," )

      @a = for_each_one

      #@email.name = for_each_one[ 0 ]
      #@email.email = for_each_one[ 1 ]
      #@email.save
      #
      #if @email.valid?
      #  @group.emails << @email
      #end

    end

action

<% @a.each do |a| %>
<%= a %>
<% end %>

return :

myemail-4cajJJ5tN1zQT0dZR+AlfA@public.gmane.org
My Name

Thank you.