I do need some help with this error:
NoMethodError in PostsController#checkin undefined method `hasToday' for #Controller:
def checkin
@date = DateTime.parse(params[:day])
if (Post.hasToday(@date))
end
Model:
class Post < ActiveRecord::B开发者_如何转开发ase
scope :created_on, lambda {|date| {:conditions => ['DATE(created_at) = ?', date.to_s(:db)]}}
def hasToday(date)
self.created_on(date).count > 0 ? true : false
end
end
try this in your modal
def self.hasToday(date)
self.created_on(date).count > 0 ? true : false
end
精彩评论