[Rails] how to set up fields_for to choose a subclass?
I have an STI model where UtilityProvider is the parent class, and
there's a sub-class for each specific utility provider.
When the user goes to choose a UtilityProvider, I want to present a
pull-down list of UtilityProvider.subclasses (or, more likely, a
filtered version of that), and when the user hits [submit] to create the
appropriate subclass.
To add a little spice to the question, I have a Premise model, and
premise has_many :utility_providers
and I'm using nested routes to represent the relationship:
resources :premises do
resources :utility_providers
end
So at the point in my code where I invite the user to create a new
UtilityProvider, I *do* have a @premise, but I don't have a
@utility_provider.
I think this requires a fields_for rather than a form_for construct with
a collection_select within it, but I'm really stumped on how to
structure the form. What's the Rails-y way to do this?
TIA.
- ff
--
Posted via http://www.ruby-forum.com/.
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home