On Tue, Feb 15, 2011 at 10:26 AM, Paul Bergstrom <[email protected]>wrote:
> Kedar Mhaswade wrote in post #981823:
> > Or since only keys are needed, use each_key iterator.
> >
> > Also, I think ri should say that the "method" each "returns" the same
> > Hash
> > on which you called the method.
> >
> > -Kedar
>
> I actually need both.
>
> Sure, each or each_pair.
> Hmm. This should output a string in view but it doesn't:
>
> <% h = { "a" => 100, "b" => 200 } %>
>
First: Consider using Symbols (not required, but ubiquitous) as that is the
Railism ;)
> <%= h.each {|key, value| puts "#{key} is #{value}" } %>
>
That's perhaps because you're dealing with output stream, (and not view of a
controller) of your Rails server when you use puts.
You should collate the response in a variable like Colin showed and just do:
<%=str %> which puts the contents of the string in the view.
HTH,
-Kedar
>
> --
> 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 [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.
>
>
--
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.