Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess/Output Values in Flattened Hash?
    primarykey
    data
    text
    <p>In my controller I have:</p> <pre><code>@invoices = current_user.account.clients.map(&amp;:invoices).flatten </code></pre> <p>and in my index.html.erb I want to display the values, currently I have the following:</p> <pre><code>&lt;% @invoices.each do |invoice| %&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;%= invoice.client.name %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= invoice.jobs.inspect %&gt;&lt;/td&gt; #HERE IS WHERE I WANT START_DATE, etc &lt;td&gt;&lt;%= invoice.created_at %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to "PDF", invoice_path(invoice, :format =&gt; :pdf)%&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to invoice, :method =&gt; :delete, :confirm =&gt; 'Are you sure you want to delete this invoice' do %&gt; &lt;i class="icon-trash"&gt;&lt;/i&gt;&lt;% end %&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; </code></pre> <p>invoice.jobs.inspect returns the following:</p> <pre><code>[#&lt;Job id: 15, start_date: "2012-03-24", due_date: "2012-03-31", notes: "grthryrth", audio_file_url: "1.txt", transcribed_file_url: "300.txt", status: "invoiced", account_id: 1, user_id: 1, client_id: 2, created_at: "2012-03-29 18:03:14", updated_at: "2012-03-29 18:40:49", invoice_id: 6&gt;, #&lt;Job id: 16, start_date: "2012-03-24", due_date: "2012-03-21", notes: "uopuiouioiio", audio_file_url: "Data Flow Analysis and Integration v1.1.docx", transcribed_file_url: "ECA-Sponsor Monthly Agenda 20120105.doc", status: "invoiced", account_id: 1, user_id: 4, client_id: 2, created_at: "2012-03-29 18:05:24", updated_at: "2012-03-29 18:40:49", invoice_id: 6&gt;] </code></pre> <p>How do I access each value individually, for example, invoice.jobs.start_date? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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