Note that there are some explanatory texts on larger screens.

plurals
  1. POIterate through model columns
    primarykey
    data
    text
    <p>I'm not sure the best way to iterate through all the columns within my Day model to benefit a simplified formatting scheme.</p> <p><code>index.html.erb</code></p> <pre><code>&lt;% @day.each do |u| %&gt; &lt;li id="date"&gt;&lt;%= clean_date(u.date) %&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt;Morning&lt;/b&gt;: &lt;%= u.morning %&gt;&lt;/li&gt; &lt;% unless u.morning_notes.blank? %&gt;&lt;li&gt;&lt;b&gt;Morning Notes&lt;/b&gt;: &lt;%= u.morning_notes %&gt;&lt;% end %&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt;Afternoon&lt;/b&gt;: &lt;%= u.afternoon %&gt;&lt;/li&gt; &lt;% unless u.afternoon_notes.blank? %&gt;&lt;li&gt;&lt;b&gt;Afternoon Notes&lt;/b&gt;: &lt;%= u.afternoon_notes %&gt;&lt;% end %&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt;Evening&lt;/b&gt;: &lt;%= u.evening %&gt;&lt;/li&gt; &lt;% unless u.evening_notes.blank? %&gt;&lt;li&gt;&lt;b&gt;Evening Notes&lt;/b&gt;: &lt;%= u.evening_notes %&gt;&lt;% end %&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt;Night&lt;/b&gt;: &lt;%= u.night %&gt;&lt;/li&gt; &lt;% unless u.night_notes.blank? %&gt;&lt;li&gt;&lt;b&gt;Night Notes&lt;/b&gt;: &lt;%= u.night_notes %&gt;&lt;% end %&gt;&lt;/li&gt; &lt;% end %&gt; </code></pre> <p>Ideally, it'd be something like:</p> <pre><code>&lt;% @day.each do |u| %&gt; &lt;li id="date"&gt;&lt;%= clean_date(u.date) %&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt;TimeOfDay&lt;/b&gt;: &lt;%= u.TimeOfDay %&gt;&lt;/li&gt; &lt;% unless u.TimeOfDay_notes.blank? %&gt; &lt;li&gt;&lt;b&gt;TimeOfDay Notes&lt;/b&gt;: &lt;%= u.TimeOfDay_notes %&gt; &lt;% end %&gt;&lt;/li&gt; &lt;% end %&gt; </code></pre> <p>Where TimeOfDay iterates through Morning, Afternoon, Evening and Night.</p>
    singulars
    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.
 

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