Forum: Ruby Large, existing database for RoR

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-03-16 01:00
(Received via mailing list)
Hi,
My organisation has a relatively large legacy database that has a java
application (using hibernate) to perform analytics on the data.

We need to develop a CRUD application for it and I have been looking at
Ruby on Rails and scffolding to do it. It does not need to be fancy
interface at all, just have an ability for CRUD.

What I am concerning about is the Id field in RoR and having it change
the datamodel. As other application are using it, is it possible to
have RoR integrate directly with an exisitng data schema without
changing it ? All the tutorials sort of do DB development when writing
the web application.

Thanks in advance, it means a lot of time would be saved!
Julian L. (Guest)
on 2006-03-16 01:16
(Received via mailing list)
Yes, you can specify what the id is.

I suggest taking a look at http://api.rubyonrails.org/

Find on ActiveRecord::Base then within that, search for set_primary_key.

Basically this is what you want to set the primary key to invId for
rails' purposes:

class Invoice < ActiveRecord::Base
	set_primary_key 'invId'
end
Jacob F. (Guest)
on 2006-03-16 01:19
(Received via mailing list)
On 3/15/06, removed_email_address@domain.invalid 
<removed_email_address@domain.invalid> wrote:
> What I am concerning about is the Id field in RoR and having it change
> the datamodel. As other application are using it, is it possible to
> have RoR integrate directly with an exisitng data schema without
> changing it ? All the tutorials sort of do DB development when writing
> the web application.

Yes, this is definitely possible. Check out the API docs on
ActiveRecord[1], specifically the set_primary_key[2] class method.
Example:

  class Project < ActiveRecord::Base
    set_primary_key "legacy_id"
  end

Jacob F.

(PS. For future reference, these questions are much better directed at
the Rails specific mailing list[3])

[1] http://api.rubyonrails.org/classes/ActiveRecord/Base.html
[2] http://api.rubyonrails.org/classes/ActiveRecord/Ba...
[3] http://lists.rubyonrails.org/mailman/listinfo/rails
unknown (Guest)
on 2006-03-16 01:25
(Received via mailing list)
that is great Julain and Jacob!! I will have a go and get back if i
have further questions!

Cheers
This topic is locked and can not be replied to.