Hello
I've created a simple rails app that has a people and a notes model.
People have many notes and notes belong to people
The app works and I'm able to show all the notes for a specific person, but I'd like to be able to show a single note for a specific date.
The default scenario being todays date.
I currently have the following:
<% @person.notes.each do |note| %>
<p>
<h3><%=h note.title %></h3>
</p>
<p><b>Body: </b><br />
<%=h note.body %>
I have tried several different methods but can't get any to show me a note for the date today.
I tried to create a named scope and failed with that and also tried to use:
@person.notes.find_by_created_at(Time.now-1.day)
Can anyone point me in the right direction please?
Thanks
Tom
#I used the code from below and came up with this.
My show view looks like this.
<p>
<h1><%=h @person.name %></h1>
</p>
<h2>Notes</h2>
<% @person.notes.all(:conditions=> ["created_at >= ? ", Time.now.beginning_of_day]) do |note| %>
<p>
<h3><%=h note.title %></h3>
</p>
<p><b>Body: </b><br />
<%=h note.body %>
</p>
<% end %>
I think I may be using the wrong syntax in my view, or should possibly not even be using this in the view?
T