RailsCasts Pro episodes are now free!

Learn more or hide this

the1drewharris's Profile

GitHub User: the1drewharris

Comments by

Avatar

OK, I fixed it by changing all my eventcategory stuff over to eventcat to keep the naming less likely to get mixed up.

Avatar

I'm using Ruby 2.0 and Rails 3.2.8 and I can't seem to get the simple has_many through part working.
In my Event model

ruby
  attr_accessible :address1, :city, :country, :description, :enddate, :eventname, :startdate, :state, :status, :url, :zip, :eventcategory_ids
  has_many :categorizations
  has_many :categorizations
  has_many :event_categories, through: :categorizations 

In my Eventcategory model

ruby
  attr_accessible :description, :eventcategory, :event_id
  has_many :categorizations
  has_many :events, through: :categorizations 

In my Categorization model

ruby
  attr_accessible :created_at, :created_by, :event_id, :eventcategory_id
  belongs_to :event
  belongs_to :eventcategory

The tables are all there for all three models.

When I run: e = Event.first in the console it gets me my first event.
Then I run: e.eventcategory_ids I get: NoMethodError: undefined method 'eventcategory_ids' for #<Event:0x00000002b7d660>

I figure that has to work before any of the rest of the stuff from this screencast will work for me... right? Am I missing something here?