Add Support for other ORMs #26

Closed
fbjork opened this Issue May 13, 2011 · 235 comments
@fbjork

First of all great job on active_admin! Impressive and really easy to get up and running.

Any plans to support other ORMs like Mongoid?

@gregbell

Yes this is definitely something on our Roadmap. So we've got a few requests for Mongoid. Any other specific ORMs for "official" support?

@jc00ke

First, thanks for the gem @gregbell!

+1 for Mongoid so I can use active_admin on my current project.

@pusewicz

How about using something more abstract for db support?

@gregbell

Yes agreed. We'll have to abstract the concept of data stores and data access. I'm just trying to get a sense for which ORMs people are interested in "Out of the Box".

@jc00ke
@Sproutworx

+1 for Mongoid. That'd be a big help for me.

@gregbell

@jc00ke Thanks for the suggestion. This seems like a great starting point.

@luma

Datamapper support would be awesome too.

@pusewicz
@PabloC

+1 for mongoid support

@apardo

+1 for Mongoid support

@rurounijones

I think (and I might be open to flame-bait here) that the most widely used NoSQL database for primary datastore for apps is mongodb. As for the ODM my impression is that Mongoid seems to be the more popular one. Therefore I would say that Mongoid would be head on the NoSQL list.

Maybe github needs polls ;)

@phosphene

+1 for mongoid!

@drewda

Over in RailsAdmin land, they're considering using either OrmAdapter or Veneer in order to support a wider range of options.

@jmcopeland

+1 for Mongoid

@cblavier

+1 mongoid

@jacobwgillespie

+1 for Mongoid

@lapluviosilla

Yes, this would be so awesome. +1

@brainopia

If you want a poll, then I'd definitely vote for mongoid :)

@juniovitorino

+1 for mongoid.

@jeremyruppel

Second @drewda's OrmAdapter suggestion, especially since it's already a dependency of devise.

@kmamykin

+1 for mongoid

@stratequip

+1 for mongoid

@nevir

Also interested in this (for DataMapper).

From a quick look into taking a stab at it, ORM adapter probably needs to be extended to be aware of more data (types of columns, being able to enumerate assocations on a model). Also, InheritedResource is pretty coupled to ActiveRecord and its finders would probably need to be overridden (and/or ORM adapter also needs to abstract out the ability to query on collections).

Veneer is probably a better starting point, currently, since it has support for introspecting the associations on a model. https://github.com/kaapa/veneer/commits/properties

@damrbaby

+1 mongoid!

@rbq

+1 for DataMapper

@devilcoders

+1 mongoid

@aubergene

+1 mongoid

@steveklabnik

Why not just do it via ActiveModel?

@docwhat

+1 ActiveModel

@nevir

ActiveModel doesn't support querying & introspection (of a table/collection); it's just a consistent representation of the individual resources - and gives you all those nice helpers, like validation

@steveklabnik

Hmm, I guess I'm just thinking about the presentation, rather than the other side of it too.

@yakshaving

+1 for Mongoid, please =)

@myabc

I'm interested in picking this up for DataMapper. To follow on from @nevir's comment, it looks like one way to get started would be to build support for DM/other ORMs low-down into inherited_resource/ has_scope, given that ActiveAdmin is built on, and strongly coupled to these gems.

@eoy
eoy commented Jun 9, 2011

+1 for Mongoid

@hindenbug

+1 for Mongoid

@carlson

+1 for Mongoid

@themusicman

+1 for Mongoid

@sradu

+1 for mongoid

@chalmagean

+1 Redis

@tmilewski

What's the status? (+1 Mongoid)

@nikolajsen

+1 for Mongoid

@Florian95

+2 for Mongoid !

@myabc
@tmilewski

@myabc Thanks, I know how/when to use the fork button. As a matter of fact, I've even indirectly contributed to AA via that same fork button on Kaminari.

I think that asking what the status is is entirely fair considering the following comment from @gregbell himself:

"Yes this is definitely something on our Roadmap." (Dated ~2 months ago)

I'd love to contribute directly to AA but I simply don't have the time to commit right now.

@myabc
@mbj

+1 for Datamapper / Generic ORM-Support

And I would like to get my hands dirty in participating in a generic orm-adapter solution. My toughts about it:

  • Do not start with a single plain datamapper fork, it will not be merged back.
  • Instead decide about an orm adapter, (ORM-Adapter or veneer?)
  • Start to port the current active record backed system to the choosen orm adapter
  • Get this merged into master
  • Start building DataMapper/Mongoid etc support with the new features by orm-adapter

Are there better ideas around?

@gregbell

@mbj That seems like a great plan for getting started.

The first thing we should do is a brief audit of the existing Active Admin code base to document all the features the data store will have to support. I would like to see Active Admin define the public API required for adapters to implement the existing features. Then we can make a decision on which generic ORM to use.

From my perspective, the biggest hurdle will be the filtering, scoping and "belongs_to" behavior on the index screens. We will need to write adapters for any support data store, but it needs to start with documenting the API.

I'm really tight for time, so if anyone has a chance, maybe we could start a wiki page that starts to document a plan

@mbj

@gregbell

Sorry for reacting not that fast.

I'll first start to read the source "in depth" and make sure I understand the hurdles you mentioned. After that I'll try to start an adapter API description. Gist based. After that we can decide to use the ORM-Adapter with the biggest "already works" part. Im sure we have to extend one of the already existing ORM-Adapters. We should start to talk to the ORM authors to make sure our requirements get their support.

As I'm really tight for time too, do not expect results this week ;)

@brendonrapp

+1 for Mongoid.

@yholkamp

@mbj, my suggestion would be to consider the orm_adapter gem you mentioned earlier, it's already being used by Devise, which gives it an slight advantage over veneer. As for the supported ORMs, it supports both ActiveRecord, DataMapper and Mongoid rather than the (according to Ruby-Toolbox and the spam in this topic) less used MongoMapper.

As far as I can tell from my brief looks through the code of active_admin and Veneer/OrmAdapter's api's, the major issue would indeed be the lack of scopes, which are used rather extensively throughout the code. Including support for the belongs_to-behavior should be rather easy to solve in comparison I think, requiring a small extension (contribution?) to the adapter's classes.

@olivierlacan

Can't wait for this to support Mongoid, congratulations on an amazing project however. I'm tempted to switch back to SQL just to play with it on my latest project.

@lgs

+1 for Mongoid support

@adamjleonard

+1 for Mongoid

@l4u

+1 for Mongoid

@bkoc

+1 for Mongoid

@jamal86

+1 for Mongoid (whats the status?)

@nevir

@nextpulse The problem with orm_adapter is that it's focused on abstracting the query interfaces - but not introspection. To make it useful for active admin, we'd need to build in support for that.

@kaapa's properties branch of veneer is probably the best starting point: https://github.com/kaapa/veneer/tree/properties

@4ware

+1 for MongoId!!

@niksosf

using mongoid, watched Ryan Bates's newest video, tried the gem, didn't work, so a friendly vote for +1 Mongoid!

@marbemac

+1 Mongoid. Also just watched the Ryan Bates screencast - would LOVE to use this for a couple companies I work for but they're all using mongoid.

I see back in June support for other ORMs was on the roadmap. Any updates as to where on the roadmap?

@mbj

@gregbell Sorry for not reacting that fast. Daily business is hard ;) I'm currently purging rails from my default development stack moving on to other targets. So I cannot invest time in active_admin to build support for datamapper (my favorite orm). I canceled my plans to port active_admin to orm adapter. Sorry.

(Edit: Spelling)

@HungYuHei

I would like to see Mongoid support

@ElvisTheKing

It will be great to have datamapper support!
Mongoid can be useful too =)

@ebeigarts

It would be very hard to get the filters working, because meta_search supports only ActiveRecord.
Maybe we could start by adding support without the filters and comments. Working example with Mongoid - https://github.com/ebeigarts/mongoid_active_admin_app

@wiktorschmidt

@ebeigarts - great stuff - this works. One needs to define all the fields manually but it's a bit step forward!

@mrcasals

+1 for datamapper!! :)

@devton

+1 for mongoid ;)

great job folks!

[]'s

@zolzaya

+1 for MongoID :)

@goshakkk

Mongoid 👍

@jcoene

+1 for Mongoid

@farukca

+1 for Mongoid support

@kennyrueter

+1 for ActiveResource support

@brennancheung

+1 for Mongoid

@szymon-przybyl

+1 for DataMapper

@lukebyrne

+1 for Mongoid

@yuki24 has said on Twitter that he has got it to work and will be adding a pull request to the main repo soon.

Fingers crossed it will be soonish.

@Arjeno

+1 for Mongoid

@yuki24

Hey there! as I tweeted a few days ago, I did make adtiveadmin work with mongoid but what I did was just modifying some lines.
so right now I'm rewriting it with Rspec/Cucumber test and preparing for a pull request.
You can see the current change here: yuki24@master...enable_mongoid

index_as_table and show already work and tested with RSpec and Cucumber. Deletion works but has not been tested yet.
also I'm working on adding orm_adapter to make it easier to support other mappers as discussed above.

try the branch if you have time and give me your feedback. Thanks!

@Arjeno

I will give this a try soon. I saw your fork/branch yesterday but didn't think it was ready for testing yet.

@thenrio

Hello @yuki24

My app is mongoid only and does not require active_record (that is no sql database, only a mongo one)

I made local edits from your code (I dropped a comment on #96bf39) to have app go further

  • rails g active_admin:install --skip-users failed on assets

    cause is : comments require a database, which I have not

  • disabling comments in config/initializers/active_admin.rb enables rails generate active_admin:assets

    config.allow_comments_in = []

Generating assets should not require a database ... (looking like a famous issue on heroku cedar with rake assets:precompile :)

I had to do some more edits in initializer to fit into its authentication path, and I'm glad I found them easily

Then, admin interface shows up
This is great

Here are the gotchas I faced :

  • index sort cause an error in app
  • new | edit empty form

I forked your fork, and will see how I can help

@marbemac

@yuki24 @thierryhenrio You guys have seen @ebeigarts fork right? It code for a working mongoid active admin (except without comments and filtering). I've gotten create, update, destroy, sort working based off of that fork with mongoid. All that he did was add an initializer (active_admin_mongoid_patchets.rb) to disable commenting and filtering and update sorting.

https://github.com/ebeigarts/mongoid_active_admin_app

What is difficult are the filters because they're reliant on meta_search which is active record only right now. I also think decent support for embedded documents needs to be added in before it's really useful.

@yuki24

@thierryhenrio thank you for the feedback! I'll try fixing rails generate active_admin:assets. also AcitveAdmin with only Mongoid is interesting so I will also try implementing it.

@marbemac yes, I've seen that fork from @ebeigarts. he posted some comments on my codelines as well and I totally agree with what he said. also I know that many things depend on active_record but that is what I am trying to solve. support for embedded documents sounds really nice.

@thorwing

sounds great!

@thenrio

@yuki24, I finally made a fresh fork...https://github.com/thierryhenrio/active_admin/tree/mongoid
(spec were red, and begin from green was easier for me)

there are 3 commits

  • 7e5ad21 enabling faster red/green feedback for rspec stack, can be cherry picked
  • 827684d can generate an active_admin:install for mongoid (--no-comments is required), can be cherry picked
  • d5c14ba wip implementation

implementation is heavily inspired by your code and @ebeigarts insights
I picked orm_adapter, and it might not be that a good fit to active_admin context ...

I went from a fresh mongoid app, and add step beginning from cli, with rspec+cucumber being green
next goal : have fields showed in a default mongoid form (if can be:)

@atipugin

+1 on Redis. Would be awesome to able someow edit translations, stored with Redis, via ActiveAdmin.

@FluffyJack

+1 for Mongoid

@khaschuluu

+1 MongoDB

@anthonyb

+1 for Mongoid

@catullo

+1 for Mongoid

@maximeg

Mongoid is quite popular for NoSQL in Rails.

So +1.

Does any official roadmap for Mongoid integration exist ?

@Ziaw

+1 for Mongoid

@danil-z

+1 for Mongoid

@shilov

+1 for Mongoid

@rwz
rwz commented Nov 1, 2011

+1 for Mongoid

@kkampen

+1 for Mongoid

@mattmon

+1 for Mongoid

@ognevsky

+1 for Mongoid

@tbbooher

+1 for Mongoid

@fbjork

+1 for Mongoid

@ctrabold

+1 for Mongoid

@mattvague mattvague closed this Feb 18, 2012
@erickreutz

Just watching..

@ognevsky

@erickreutz there is a link below: enable notifications for this issue for these purposes.

@erickreutz

@ognevsky oh my bad. Sorry about that.

@cdussud

Anyone have an updated patch for Mongoid? Looks like the patch from @moa3 is out of date. I'm getting an error when sorting columns: wrong number of arguments (0 for 1).

activeadmin (0.4.2) lib/active_admin/helpers/scope_chain.rb:15:in scope_chain'
activeadmin (0.4.2) lib/active_admin/resource_controller/collection.rb:93:in
scope_current_collection'

Edit: Nevermind.

I dug around a bit more. Looks like I had a model with a scope called :open AND a method with the same name. The scope chain ended up attempting to call my model's method instead of the mongoid mixin. Renaming it to :opened made the problem disappear.

@k504866430

I get the following error with activeadmin(0.4.2) and @moa3 's patch.

ActionView::Template::Error (undefined method reorder' for []:Array):
1: render renderer_for(:index)
mongoid (2.4.3) lib/mongoid/criteria.rb:384:in
method_missing'
activeadmin (0.4.2) lib/active_admin/views/pages/index.rb:41:in `items_in_collection?'

Any ideas?

@nanobeep

@k504866430

I also ran into this error. Here's a fork of @moa3 's patch with a quick fix:
https://gist.github.com/1978117

@k504866430

Thank you. I will try it and get back to you.

@k504866430

Thankyou @nanobeep . It worked!!!

@elia

@mattvague is the work on multi-ORM (and on extracting Arbre) being done on some branch?
…or I should rather start one myself?

@elia

In the meanwhile I've released activeadmin-mongoid, that incorporates an analogous hack.

Any contribution or feedback is welcome :)

@stigi

@ella perfect! also works with 0.4.3.

Two things I added to make delayed_job jobs manageable.

Delayed::Job.send(:include, Kaminari::MongoidExtension::Document)
Delayed::Job.send(:include, ActiveAdmin::Mongoid::Document)
@elia

@stigi thank you!

(I'm @elia, btw)

@stigi

@elia uh, sorry :) time to clean my screen ;)

@jjoaquim

+1 for mongoid

@caifara

+1

@ericgross

+1 for mongoid

@pyrat
@DavidAllison

Any recent thoughts on Datamapper support?

@aduncan

+1 for mongoid (need a special button for this ;-)

@cmccorvey

+1 for mongoid

@jerryshen

+1 for mongoid

@smudge

Hey, all. +1s no longer add to this discussion. The overwhelming support has been made clear. Multi-ORM support is on the feature roadmap. Sorry to complain -- Yes, I could just disable notifications, except then I'd miss out on any actual discussion. (And the roadmap links to this page for that exact purpose.)

For impatient +1-ers, check this out (kudos to all who have contributed):
https://github.com/elia/activeadmin-mongoid

@lukaso

I've just posted a pull request to ActiveAdmin-Mongoid to support search filters. Hopefully this helps someone! elia/activeadmin-mongoid#15 or get the full version from https://github.com/simplybusiness/activeadmin-mongoid (if/until the pull request is merged).

@ungsophy

Hi all, I'm interested in working on adding support for other ORMs and I looked Active Admin code base for sometimes but I'm not quite sure where to start. AA depends on Inherited Resources to perform CRUD operations. Is it a good idea to make IR support multiple ORMs first? Advices from anybody would be appreciated, especially from @gregbell and other AA contributors.

@Maay

+1 for mongoid

@olliem

+1 for mongoid

@kevinzen

+1 for mongoid

@daraosn

+1 for mongoid

@elthariel

+1 for mongoid

@aminhotob

+1 for mongoid

@esummers

+1 for mongoid

@s12chung

+1 for mongoid

@mikedanese

MONGOOOOOOID!!!!

@fermuch

+1 for mongoid

@bulleric

+1 for mongoid

@Leo-ajc

+1 for mongoid

@pavellob

+1 for mongoid

@regedor

+1 for mongoid

@alexjamesbrown

closed, yet still a +1 for mongoid

@quentindecock

+1 for mongoid

@stevoyoung

+1 for mongoid

@daninfpj

+1 MongoId

@hadees

another +1 for Mongoid

@joel

+1 for mongoid

@dbaillargeon

+1 for DataMapper

@amirci

+1 for mongoid

@mez
mez commented Feb 6, 2013

+1 for mongoid

@kushkella

+1 for mongoid

@seanlinsley
Active Admin member

You guys need to work on your :trollface: skills. 2/5

But seriously, if so many people want this, why don't you build it? This is open source, after all.

@spockz

I would be interested in developing this for DataMapper (either v1 or v2) but could someone tell me how much work that would entail? Is Active Admin geared towards supporting different backends already and have there been people who have taken a shot at this?

@szymon-przybyl

I'm also thinking about developing this for DataMapper, maybe soon will try it out and see how much work will be required.

@OptimisticMonkey

+1 for mongoid

@leemour

+1 for mongoid

@timtch

+1 for mongoid

@zoer

+1 for mongoid

@ReneVallecillo

+1 for mongoid

@micred

+1 for mongoid

@seanlinsley
Active Admin member

me 🔫

@seanlinsley
Active Admin member

Well at least this hasn't devolved into meme images.

@Bijendra

would surely go with mongoid +1

@davearonson

+1 for Riak/Ripple just because I'm trying to get that combo to work for a client right now. :-)

@gfrare

+1 for mongoid

@richarddong

+1 for mongoid

@unorthodoxgeek

currently it's +102 for mongoid.
I'd add my own +1 for mongoid
so it's 103 +1s

@mrjlynch

+1 mongoid

@elia

Well at least this hasn't devolved into meme images.

@Daxter sounds like a call to action 😎

@seanlinsley
Active Admin member

A call to action for someone to either dedicate time or money towards this, yes. 🐙

@seanlinsley
Active Admin member

Speaking of time, if anyone wants their ORM of choice supported and is willing to spend some time pair programming with me, let me know!

@seanlinsley
Active Admin member

anyone ⁉️

@elia

@Daxter I'd love to do that, especially porting stuff from activeadmin-mongoid, but sadly have no time these days

@spockz

I would've liked to join you, however, I'm currently not on a Ruby/Rails project and my time is needed elsewhere. So, sadly, I cannot help.

@rottmanj

@daxter

I have a large amount of free time and I have a few other people who would be willing to help with getting ActiveResource working with AA

@seanlinsley
Active Admin member

@elia & @spockz, no worries :)

@rottmanj, great! Except, what do you mean by ActiveResource? It's our reliance on ActiveRecord that's the problem.

@rottmanj

@daxter

I am referring g to adding activeresource support within active admin.

There was a request for this in #39

@seanlinsley
Active Admin member

I still don't know what you mean by that. Could you elaborate?

@rottmanj

@Daxter

Right now you can not use a model that inherits from active resource as a resource with in active admin.

@redrick

How are you guys ( @rottmanj ) on the ActiveResource with AA? It would suit my needs perfectly :) +1

@Funfun

+1 mongoid

@seanlinsley
Active Admin member

+1's on this only help to make myself and other maintainers more stressed about this topic. Please either help or donate.

@candreoliveira

+1 mongoid.... fast fast

@seanlinsley
Active Admin member

@candreoliveira did you not see my comment above? You can help by donating time or money.

@usmanarif

+1 for Riak with Ripple. As I didn't get any working Activeadmin in Riak based application.

@tzmgit

+1 mongoid

@mayatskiy

+1 mongoid

@Seaborg

+1 mongoid

@sanalpencere

+1 mongoid

@dsylla

+1 mongoid

@dmitrypol

+1 mongoid

@flaviomori

+1 mongoid

@juni0r

+1 for Mongoid

@elia elia referenced this issue in elia/activeadmin-mongoid Oct 6, 2014
@elia elia Broken filters & passive maintenance 6d408f0
@mmenafra

+1 mongo id
+1 redis

gogogogo

@vekozlov

+1 mongo id

@seanlinsley
Active Admin member

Go to #2714 to test Mongoid integration instead of 👍ing this ticket.

@seanlinsley seanlinsley locked and limited conversation to collaborators Oct 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.