Rails belongs_to issues
- by Rahul
I was trying to follow the answer provided by this post
About Event_calendar.Showing only events for current user and not all events present
However when I tried to add the belongs_to user in the event model, it gives me the following error.
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)
in my user.rb model I have included has_many :events
Any idea how to fix this?