Large, existing database for RoR

Discussion in 'Ruby' started by johntwinn@gmail.com, Mar 15, 2006.

  1. Guest

    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!
    , Mar 15, 2006
    #1
    1. Advertising

  2. 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

    On 16/03/2006, at 9:58 AM, wrote:

    > 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 Leviston, Mar 15, 2006
    #2
    1. Advertising

  3. Jacob Fugal Guest

    On 3/15/06, <> 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 Fugal

    (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/Base.html#M000741
    [3] http://lists.rubyonrails.org/mailman/listinfo/rails
    Jacob Fugal, Mar 15, 2006
    #3
  4. Guest

    that is great Julain and Jacob!! I will have a go and get back if i
    have further questions!

    Cheers
    , Mar 15, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nrm
    Replies:
    3
    Views:
    527
  2. Ketchup
    Replies:
    1
    Views:
    241
    Jan Tielens
    May 25, 2004
  3. shurain
    Replies:
    5
    Views:
    111
    Brian Adkins
    May 2, 2007
  4. Replies:
    0
    Views:
    183
  5. Replies:
    5
    Views:
    872
    Xho Jingleheimerschmidt
    Apr 2, 2009
Loading...

Share This Page