title: Array Of ActiveRecord::Base.connection.execute Ruby On Rails
body: <p>I am a newbie to rails and i needed to execute some sql query and array output it to the view.</p>
  
  <p>on conttroler</p>
  
  <pre><code>@accounts = Account.all
   @itemlist = Account.find(:all,:select =&gt; 'subdomain')
  
   @schemasize = ActiveRecord::Base.connection.select_rows(%q{select pg_size_pretty(CAST((SELECT SUM(pg_total_relation_size(table_schema || '.' || table_name) ) FROM information_schema.tables WHERE table_schema = '}+@itemlist.map(&amp;:subdomain).join(" ")+%q{') As bigint) )  As schema_size}).to_s.gsub(/\D/, '').to_f / 1024
  </code></pre>
  
  <p>output on command</p>
  
  <pre><code>  Account Load (36.0ms)  SELECT "public"."accounts".* FROM "public"."accounts"
    Account Load (2.0ms)  SELECT subdomain FROM "public"."accounts"
     (88.0ms)  select pg_size_pretty(CAST((SELECT SUM(pg_total_relation_size(table
  _schema || '.' || table_name) ) FROM information_schema.tables WHERE table_schem
  a = 'subdomain1 subdomain2') As bigint) ) As schema_size
    Rendered accounts/kapasitas.html.erb within layouts/admin (239.0ms)
  Completed 200 OK in 2765ms (Views: 2208.1ms | ActiveRecord: 484.0ms)
  </code></pre>
  
  <p>on html.erb</p>
  
  
  
  <pre><code>  &lt;tr&gt;
      &lt;td&gt;&lt;%= account.subdomain %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= @schemasize %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  
  
  <p>output on view : <a href="http://i.cubeupload.com/jVrShN.png" rel="nofollow">http://i.cubeupload.com/jVrShN.png</a></p>
  
  <p>cannot schema of size per subdomain.</p>
  
  <p>i want output such as : <a href="http://i.cubeupload.com/PMPBYn.png" rel="nofollow">http://i.cubeupload.com/PMPBYn.png</a></p>
  
  <p>How can I do that?
  any idea?</p>