Open simonhildebrandt opened 13 years ago
I have no experience with couchdb. How is a polymorphic association done in couchdb?
Basically the same way as SQL - since the DB itself doesn't support it you'd build it into the ORM layer. The problem is that the ORM layer I'm using (CouchRest::Model) only supports some of the features of ActiveRecord, and :polymorphic isn't one of them.
For the moment I've overriden DeviseInvitable's belongs_to call, since I don't need polymorphism anyway - in the future I might try hacking :polymorphic support into CouchRest::Model. I would consider that the ultimate goal - I only brought it up here because of all the ORM adapter and mapping calls appearing in Devise. :)
You run into the same thing when using DataMapper :(
My solution was also to kill off the :polymorphic flag (Users inviting Users is good enough for my case) - also had to disable the creation of the invited_by_id and invited_by_key columns, since DataMapper does that for belongs_to calls
I had to do some of these same changes to get invitable working with devise on DataMapper 1.2.0, Rails 3.2.8 and Ruby 1.8.7. My branch is here: https://github.com/phillbaker/devise_invitable, for those interested.
I tihnk some of needed changes are already in devise invitable (two adapters are supported and polymorphic association can be disabled). Is it enough?
@scambra, it's been a while since I worked on that project, if I have time, I'll give it a shot.
thanks a lot @phillbaker
devise_invitable has perfectly scratched my itch for invites, and since I need the invited_by field I've just upgraded to v0.4.rc5. Problem is that couchrest::model doesn't understand :polymorphic => true and barfs on the belongs_to association in the Invitable mix-in.
I've noticed that Devise is pushing towards being ORM-agnostic (something about to_adapter etc. that I'm still trying to wrap my head around) - any chance of devise_invitable hooking in to the same stuff?
(If not, what's the most graceful way of overriding this?) Thanks. :)