views:

91

answers:

1

I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and so on, but I am concerned about using RoR with existing non-MySQL databases. I know RoR can communicate with non-MySQL; in fact, I am using jRuby on Rails so I can use JDBC.

My question is how RoR works with existing database. Do I lose all the benefit of using RoR when I'm using existing databases? I don't want to always genearate updates and what not. I have to be careful of that as it is very senstive. I just feel like learning all this framework "stuff" may be for naught because the majority of what I will be doing is not a new database and all the "fancy" stuff RoR does will not even make sense for me. And I absolutely cannot change the data to another databases. I have many different databases to hit and bring back in one webpage.

FWIW, I am used asp.net (non-MVC), table adapters, and ODBC (all intranet), but am not on a Microsoft server at the moment. I am on Mac OS X Server 10.5.7, jruby, jdbc, ror.

Am I using the wrong framework for what I need? I can easily see PHP working like Classic ASP, but I cannot yet picture this for RoR and I do not want to use php, if I don't have to. JSP and the J2EE stack is a possibility.

Thank you.

EDIT: Is there any advantage to using RoR in this context? I asked this to the Django folks a year of so ago and was just told that maybe it wasn't good for legacy data. I don't want to make it work like a round peg in a square hole just so I can say I'm using RoR and ruby. Would I better off with j2ee, hibernate in this?

EDIT: Is J2EE and MVC the better way to go for what I have described?

+2  A: 

It works, but you have to do a lot more work to make things happen.

The usual pain points when you're using an existing schema with ActiveRecord / Rails are:

  • table names
  • foreign key names
  • primary keys (especially composite primary keys)

ActiveRecord makes a whole bunch of assumptions about how you have things set up. There are overrides in a lot of cases, but not everything. You can usually get most of the way there unless you're doing weird things in your table structure to start with.

madlep
I'd also add that if there's something you have no way to solve at all, you can feel free to ping members of the Rails team (yes, I'm making an open invitation), and we can see about an extension or core change that would make it possible to use ActiveRecord with a legacy database. There is also an alternative ORM called DataMapper which will be 100% compatible with the next version of Rails and has much better explicit support for legacy databases.
Yehuda Katz