I am creating a small lesson application with a different lesson for every day. I want to show the current lesson only by index and cannot figure out how to do this. I googled and found some information that came close but still could not solve the problem. I have only one controller, DaysController. There is no user controller.
For my model (day.rb) I tried this
class Day < ActiveRecord::Base
validates :description, :date, :link_to, :presence => true
scope :created_on, lambda {|date| {:conditions => ['created_at >= ? AND created_at <= ?', date.beginning_of_day, date.end_of_day]}}
def self.today
self.created_on(Date.today)
end
end
And for my index, I tried these
<% @day.created_on(Date.today) %>
<% @day.today %>
any advice
source
share