From: Dave Howell Date: 2010-06-08T07:05:08+09:00 Subject: Re: Looking for ORM for 'legacy' database. On Jun 6, 2010, at 15:55 , Phrogz wrote: > > I encourage you to give Sequel a long, hard investigation before > discounting it. Oh, believe me, Sequel has never been 'discounted.' Just my own digging had Sequel as one of the three top candidates on my list. On Jun 6, 2010, at 7:03 , Edward Middleton wrote: > > I am in no way advocating you do it this way but if you are going to > throw away all the advantage of using a good domain model[1] then you > may as well just pass data to your templating engine. Postgresql has a > driver ruby-pg[2], thats probably what you want. I've got a number of scripts already that drive data in and out of Postgres 'directly,' but I've been assuming that once I add a templating engine and web adapter, that they'll be much easier to use if I'm giving them Ruby objects that look like what ORMs make, rather than a big array or some such. I still haven't figured out what, exactly, a Domain Model will do for me, or even exactly what it is, but I'm not (deliberately? consciously?) trying to throw those advantages away. Thanks for the links. On Jun 5, 2010, at 14:46 , Walton Hoops wrote: > So assuming you already have a table named 'demos' in your database, you > can just run 'script/generate model demo' and TADA! It works. Except that it didn't. I tried that, but I just ended up a bit sad and rather puzzled. > Or if you > want, you can just create the demo.rb file in your app/models directory > and that will work too. Er, OK. But **how**? Everything I've found just assumes I'll use the magic script command to make it. Nothing tells me "here's how you'd build one by hand, if you were so crazy that you'd want to do it that way." > As for UUIDs as PKs, you'll notice in the example above that I > used strings as a PK with no difficulty. UUIDs should work the same way. I've thought so, too. But I just ended up with a whole lot of "Could not create table blahblahblah. Unrecognized data type UUID." messages in the file. I'd post it verbatim, but I'm afraid I've already wiped the test folder and de-installed Rails. On Jun 5, 2010, at 0:17 , John W Higgins wrote: > I'm surprised you mentioned Sequel in that list [of things with Rails-centric documentation] > because Sequel is very much > non-rails based and I've not seen much mention of rails in the docs at all ( > http://sequel.rubyforge.org/). I admit that the quick sample on the home > page does create a table but that is much more in the sense of having a > sample that is self-contained rather then forcing you to do anything at all > in terms of creating the schema within Sequel. I was probably overly broad in my characterization. I believe, actually, that I read through the Sequel documentation fairly early in my research, and ran across the "how to make a table in your database from within Sequel," did NOT find a "how to make Sequel construct an object FROM your table" as easily, and moved on to some of the other candidates in the list just because I was trying to learn a little bit about everything first. While creating a table in the DB from an object isn't intrinsic to Rails, it does reflect the object-centric (vs. database-centric) perspective that keeps coming between me and the information I really want to find. So: lots of votes for Sequel. I am installing the gem even as I write this. Thank you all, and for the sake of posterity, archiving, and others who might come along later wondering the same thing, I'll do a follow-up post with the results.