Felipe Pieretti Umpierre wrote in post #1046832:
> 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.

As far as I can tell it's doing exactly what you asked it to do:

Let me explain....

> emails_controller.rb
>
> emails = params[ :email ][ :email ].split( ";" )
> @e = emails
>
> action
> <%= @e %>
>
> return : ["myem...@first.com,My Name", "myem...@second.com,My Name"]

Your array with two elements...

> emails_controller.rb
>

Enumerate each of the two elements...

> emails.each do |e|
>       for_each_one = e.split( "," )
>
>       @a = for_each_one

1. First time through set @a to a new array containing the split of the 
first element
2. Second time through replace @a with new array containing the split of 
the second element

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

Enumerate the two elements contained in @a (i.e. [ 'myem...@second.com', 
'My Name' ])

> <% @a.each do |a| %>
>     <%= a %><br />
> <% end %>
>
> return :
>
> myem...@second.com
> My Name

End of line....

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to