using ActiveRecord outside of rails

28 views
Skip to first unread message

peter cowan

unread,
Dec 22, 2011, 7:31:51 PM12/22/11
to pdxruby-...@googlegroups.com
hi pdx rubyists,

i'm doing a little side project in ruby and i need to add persistence to one object. i'm leaning towards just using ActiveRecord because it is familiar and i think i might one day use this project with rails, but i've also got a nagging feeling that there might be a better way, plus what if i decide to go with sinatra over rails? also, i hoping to avoid anything as low level as the DBI module. 

any thoughts?  

-peter

Sam Livingston-Gray

unread,
Dec 22, 2011, 8:40:00 PM12/22/11
to pdxruby-...@googlegroups.com
There's nothing wrong with using ActiveRecord outside of Rails, and it's fairly straightforward to use with Sinatra as well. The real danger with it is that, like any ORM, it encourages you to think of your object in terms of database tables, which can inhibit design.

--
(Sent from phone; please excuse brevity.)

Allen Goodman

unread,
Dec 23, 2011, 1:34:31 AM12/23/11
to pdxruby-...@googlegroups.com
Hi Peter,

While I'd agree with Sam's premonition, *some* of the design
constraint can be neutralized by using a non-ActiveRecord patterned
ORM. For example, traversing complex object graphs with DataMapper
(datamapper.org) is trivial. Moreover, since DataMapper constructs
your database schema from your models, it's possible to obviate
migrations. This is an especially useful feature while prototyping.

Best,
Allen

Sam Livingston-Gray

unread,
Dec 23, 2011, 2:10:01 AM12/23/11
to pdxruby-...@googlegroups.com
Though it's worth pointing out that DataMapper actually implements the Active Record (note the space) pattern. ;)

--
(Sent from phone; please excuse brevity.)

Jesse Cooke

unread,
Dec 23, 2011, 3:49:15 AM12/23/11
to pdxruby-...@googlegroups.com

I've used both Datamapper & Mongoid in Sinatra apps with nice results. Depending on what this app is doing you might give it a whirl in MagLev.

peter cowan

unread,
Dec 23, 2011, 1:41:55 PM12/23/11
to pdxruby-...@googlegroups.com
cool. in this case the object really just needs to represent the corresponding table, so the are no design conflicts in going with ActiveRecord.

Allen thanks for pointing out DataMapper, looks like the inverse of ActiveRecord in some ways.

Jesse, the app is going to download ~2 million nonprofit records from the IRS website, pipe them into a database, geocode the addresses, and then the web front end will provide a nice search/map interface. i am leaning towards rails because I have yet to see a ruby job posting that does not say something like "you can make rails bend to you will", and so even though i prefer the simplicity of sinatra for such a small project, i feel i should experience bending rails to my will at least once.

Sam Livingston-Gray

unread,
Dec 24, 2011, 12:22:52 AM12/24/11
to pdxruby-...@googlegroups.com
I've been itching to play with MagLev. Any resources I should look at?


--
(Sent from phone; please excuse brevity.)

Jesse Cooke

unread,
Dec 24, 2011, 12:53:21 AM12/24/11
to pdxruby-...@googlegroups.com

So far the best ones are in the examples dir & the few things I've done for the group.

@jc00ke
n-tier engineer

Reply all
Reply to author
Forward
0 new messages