How do I print an array in Rails?

Posted by Abid Hussain on Stack Overflow See other posts from Stack Overflow or by Abid Hussain
Published on 2013-10-22T14:12:09Z Indexed on 2013/10/22 15:54 UTC
Read the original article Hit count: 560

I am new to Rails and I am using Ruby version 1.9.3 and Rails version 3.0.0.

I want to print an array in Rails. How do I do that?

For example, we have to use print_r to print an array in PHP:

<?php

$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);

?>

Output:

<pre>
Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
)
</pre>

How do I print an array in Rails?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby