Rails belongs_to issues

Posted by Rahul on Stack Overflow See other posts from Stack Overflow or by Rahul
Published on 2012-11-17T22:53:07Z Indexed on 2012/11/17 23:00 UTC
Read the original article Hit count: 338

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby