devise_invitable icon indicating copy to clipboard operation
devise_invitable copied to clipboard

ORM-agnosticism

Open simonhildebrandt opened this issue 14 years ago • 7 comments

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. :)

simonhildebrandt avatar Mar 25 '11 03:03 simonhildebrandt

I have no experience with couchdb. How is a polymorphic association done in couchdb?

scambra avatar Mar 29 '11 15:03 scambra

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. :)

simonhildebrandt avatar Mar 30 '11 00:03 simonhildebrandt

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

nevir avatar Mar 30 '11 17:03 nevir

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.

phillbaker avatar Oct 22 '12 12:10 phillbaker

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 avatar Sep 17 '13 15:09 scambra

@scambra, it's been a while since I worked on that project, if I have time, I'll give it a shot.

phillbaker avatar Sep 18 '13 00:09 phillbaker

thanks a lot @phillbaker

scambra avatar Sep 18 '13 08:09 scambra