Association In rails

Jean-Sébastien D.
Mon, 16 Jul 2012 14:29:17 -0000

Here what I have
tv_show.rb
class TvShow < ActiveRecord::Base

  has_many :tv_show_managers
  has_many :customers, :through => :tv_show_managers

  attr_accessible :description
end

tv_show_manager.rb
class TvShowManager < ActiveRecord::Base

  belongs_to :customer
  belongs_to :tv_show
 attr_accessible :activated_field, :customer_id, :friendship_group_id,
:modify_on, :tv_show_id, :visible
end

customer.rb
class Customer < ActiveRecord::Base

  has_one :date_of_birth
  has_one :customized
  has_one :customer_state
  has_many :tv_show_managers
  has_many :tv_shows, :through => :tv_show_managers
 attr_accessible :approval_pending, :consent, :first, :is_activated,
:last, :last_visited, :normal_avatar, :organization_level_id, :password,
:registered_on, :security_answer, :security_level, :security_question,
:timezone, :username, :version
end

Essentially A customer may have many managers. A Manager is assign to
one tv_show

What his wrong with my code?