Re: Association In rails

Colin Law
Mon, 16 Jul 2012 14:44:34 -0000

On 16 July 2012 15:29, Jean-Sébastien D.
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> 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?

Give us a clue.  Are you getting an error of some sort?  If so it
might be helpful to tell us what it is, we are not telepathic (at
least I am not).  Don''t forget to show us the bit of code generating
the error if any.

Colin

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.