This is part of what has_many :through is for. You already have an
enrollments model, so you can just create a controller for it, adding
extra attributes where necessary (cancelled, etc.).

-eric

On Apr 1, 11:38 am, mark_d <[email protected]> wrote:
> Hi.
>
> I have a problem deciding the best way to manage a many_to_many
> relationship.
>
> It define the relationships as so:
> [code]
> ## models
> # student model
> student has_many subjects :through => :enrollments
>
> # subject model
> subject has_many students :through => :enrollments
>
> # enrollments model
> belongs_to  :student
> belongs_to  :subject[/code]
> How can I have a separate controller to manage a students enrollments
> from one page? Imagine a student page with radio buttons defining
> their relationship with a subject, something like [enrolled, deferred,
> cancelled] for example. This would surely be a one_to_one relationship
> from a routing perspective. My idea was to define this extra
> controller but I'm quickly thinking I'm going the wrong way with this.
> [code]
> map.resources :student, :has_one => :curriculum, :except =>
> [:new, :create][/code]
> Within the controller and the view, what would the form_for be for?
> There is no curriculum model, and I can't have a form_for a
> relationship (can I?).
>
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to