Thank you much. I get it now!

On Tue, Aug 31, 2010 at 1:37 PM, Michael Pavling <[email protected]> wrote:

> On 31 August 2010 20:24, Todd Weeks <[email protected]> wrote:
> > Im not getting the output I expect. In the tutorial I am doing. It is
> > suppose to just write the values to the browser.
> > Which would write a,b,c to the browser and shouldn't also be showing the
> > array brackets or double quotes.
> > Then I would be able to continue to call the values of the array and
> write
> > the results to a browser using ruby code within the erb file.
> > My question: Whats wrong with the code I'm writing?
>
> There's nothing wrong with your code, it's working perfectly. But if
> you want to iterate the array, there are several ways.
> Most commonly, you can use ".each":
>
> <% array = ['a','b','c']  %>
> <% array.each do |element| %>
>  <%= element %>
> <% end %>
>
> but if the format you've noted is specific ("a,b,c") then you can use
> the ".join" method:
>
> <% array = ['a','b','c']  %>
> <%= array.join(", ") %>
>
>
> I would recommend having a play with the Enumerable and Array API pages:
> http://ruby-doc.org/core/classes/Enumerable.html
> http://ruby-doc.org/core/classes/Array.html
>
> Rails add more functionality to these, but getting a grasp on the Ruby
> will help.
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
Warm Regards,
Todd Weeks
[email protected]
801.814.9084

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to