Note that there are some explanatory texts on larger screens.

plurals
  1. POSuppress closure return value in ruby on rails erb file
    text
    copied!<p>I have a simple erb template that pulls information from a (Grit) git repository. It displays the information just fine, but it also displays the return value of the closure which is the array of commits I'm iterating through. I found a similar question <a href="https://stackoverflow.com/questions/3648264/how-can-i-prevent-the-printing-of-the-return-value-of-a-closure-in-rails">here</a>, but the solution does not change my output at all.</p> <pre><code>#controller method for home def home @repo = Repo.new("/home/matt/gitrepo") end #home.html.erb &lt;%= @repo.commits[1..3].each do |commit| %&gt; &lt;%= content_tag(:div, "#{commit.author}", :class=&gt;"author") %&gt; &lt;% end %&gt; </code></pre> <p>the page output is </p> <pre><code>Matt Phillips Matt Phillips Matt Phillips [#&lt;Grit::Commit "e761477be972855b0c4273c1c7837baa25178210"&gt;, #&lt;Grit::Commit "18140c17632fae7dbf33cdd5e372f96ebe8104de"&gt;, #&lt;Grit::Commit "f7e8ee090bb3e8259627179287d1722c328b614f"&gt;] </code></pre> <p>How can I suppress the array? </p> <p>EDIT: Here's what it looks like in irb</p> <pre><code>ruby-1.9.2-p180 :011 &gt; include Grit =&gt; Object ruby-1.9.2-p180 :012 &gt; @repo = Repo.new("/home/matt/gitrepo") =&gt; #&lt;Grit::Repo "/home/matt/gitrepo/.git"&gt; ruby-1.9.2-p180 :013 &gt; @repo.commits[1..3].each do |commit| ruby-1.9.2-p180 :014 &gt; puts commit.author ruby-1.9.2-p180 :015?&gt; end Matt Phillips Owen Johnson Matt Phillips =&gt; [#&lt;Grit::Commit "e761477be972855b0c4273c1c7837baa25178210"&gt;, #&lt;Grit::Commit "18140c17632fae7dbf33cdd5e372f96ebe8104de"&gt;, #&lt;Grit::Commit "f7e8ee090bb3e8259627179287d1722c328b614f"&gt;] ruby-1.9.2-p180 :016 &gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload