I am using Ruby 1.9.3 and Rails 3.2.6. I want to create a page where users can invite friends to sign up. The page would contain a number of fields where a user can enter email addresses. I would like these stored in an array. Basically each field on the page would be an element in the array. My hope is to loop through the array elements, verify each email address entered, update a temp email field on my table then launch an ActionMailer to send the invite email.
I would like this array initialized each time the user goes to the invite page. From what I have read in the book Programming Ruby 1.9 I should be able to declare an array like this somewhere.
friend_email = Array.new
I need the variable available long enough to access it in my controller when I verify the data entered in my view. From my limited understanding of variables they generally are not available outside of where they are declared aka initialized. This makes it interesting when trying to send entered information to a mailer. I have used temp fields on my model to simplify things.
If there is a better way to do this I would appreciate the information. I will also continue doing research. I have seen only the one I list below where an array is populated by an existing table then displayed in a view. I want to populate the array from the view.
Render an array in a view in ruby on rails
Any help would be appreciated.