schof
2008-Apr-24 17:18 UTC
How can I "select" a model to add to my has_many relationship?
Here''s the situation ... Client has_many :licenses, :as => :holdable Vendor has_many :licenses, :as => :holdable License belongs_to :holdable, :polymorphic => true License belongs_to :asset So when creating/editing an asset, I also need to create/edit the licenses associated with that asset. I need an intuitive way to allow the user to select from a list of possible "holders" and assign one to a license. My idea was to have some sort of AJAX "suggest" type field where the user would type in the name of the holder and you get the right object back. Anyways, I''m having a hard time coming up with an elegant way to populate the asset''s holdable property using AJAX. Any ideas on how I could pass the info during a create/update? TIA, Sean --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
felipekk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-24 17:28 UTC
Re: How can I "select" a model to add to my has_many relationship?
This Railscasts episode might give you some ideas on how to achieve that: http://railscasts.com/episodes/102 On Apr 24, 10:18 am, schof <sean.schofi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Here''s the situation ... > > Client has_many :licenses, :as => :holdable > Vendor has_many :licenses, :as => :holdable > > License belongs_to :holdable, :polymorphic => true > License belongs_to :asset > > So when creating/editing an asset, I also need to create/edit the > licenses associated with that asset. I need an intuitive way to allow > the user to select from a list of possible "holders" and assign one to > a license. My idea was to have some sort of AJAX "suggest" type field > where the user would type in the name of the holder and you get the > right object back. > > Anyways, I''m having a hard time coming up with an elegant way to > populate the asset''s holdable property using AJAX. Any ideas on how I > could pass the info during a create/update? > > TIA, > > Sean--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
schof
2008-Apr-24 17:56 UTC
Re: How can I "select" a model to add to my has_many relationship?
Wow! That is a great solution. I''ve seen that guys screencasts a few other times but they''ve fallen off my radar lately. Thanks for the great suggestion. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---