我有错误
未定义的方法 events_and_repeats' for#<Class:0x429c840>
app/controllers/events_controller.rb:11:in `index'
我的 app/models/event.rb 是
class Event < ActiveRecord::Base
belongs_to :user
validates :title, :presence => true,
:length => { :minimum => 5 }
validates :shedule, :presence => true
require 'ice_cube'
include IceCube
def events_and_repeats(date)
@events = self.where(shedule:date.beginning_of_month..date.end_of_month)
return @events
end
end
应用程序/控制器/events_controller.rb
def index
@date = params[:month] ? Date.parse(params[:month]) : Date.today
@repeats = Event.events_and_repeats(@date)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @events }
end
end
怎么了?