我试图遵循这篇 关于 Event_calendar 的帖子提供的答案。仅显示当前用户的事件,而不是所有存在的事件
但是,当我尝试belongs_to user
在事件模型中添加时,它给了我以下错误。
NameError (undefined local variable or method 'user' for #<Class:0x007fff15d1f6c0>):
app/models/event.rb:3:in '<class:Event>'
app/models/event.rb:1:in '<top (required)>'
app/controllers/calendar_controller.rb:9:in 'index'
Rendered .../.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.8ms)
Rendered .../.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.0ms)
Rendered .../.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (23.6ms)
在我的 user.rb 模型中,我包含了has_many :events
知道如何解决这个问题吗?