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

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.

This Railscasts episode might give you some ideas on how to achieve
that:

http://railscasts.com/episodes/102

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs