Iterate Through Params

19 views
Skip to first unread message

BeeRich33

unread,
Jan 26, 2015, 3:11:01 PM1/26/15
to ha...@googlegroups.com
Hi folks.  I want to display the parameters in a nice way, iterated through each param and display the key and its value.  How can I get this done?

This is what I have:

    -a = params.count
   
- 0..a do |i|
       
%p= "#{params.keys[i]} = #{params.values[i]}"

All I get is an ISE.  Still getting used to the syntax here.  

Any advice appreciated.  Cheers

Norman Clarke

unread,
Jan 26, 2015, 5:59:46 PM1/26/15
to ha...@googlegroups.com
Try `params.each do |key, value|`.

--
You received this message because you are subscribed to the Google Groups "Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haml+uns...@googlegroups.com.
To post to this group, send email to ha...@googlegroups.com.
Visit this group at http://groups.google.com/group/haml.
For more options, visit https://groups.google.com/d/optout.

BeeRich

unread,
Jan 26, 2015, 8:33:28 PM1/26/15
to ha...@googlegroups.com
Actually got it to work:

-a = params.count
- (0..a).each do |i|
%p #{params.keys[i]} = #{params.values[i]}
> You received this message because you are subscribed to a topic in the Google Groups "Haml" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/haml/6g7qg7l1Zxw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to haml+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages