Forum: Ruby on Rails Several newbyish questions about Rails

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.
Lc D. (Guest)
on 2008-10-20 20:11
Hi,

I am creating a Rails application and I've run into a couple of snags.
Answers to the following questions would be appreciated.

Couple of things to note: I am using a legacy database where all of the
tables have an integer primary key called "id."

The application has to coexist with a Java/Hibernate application. The ID
for all tables is generated using a Hibernate sequence number. The same
sequence is used for all tables.

I am using Postgres 8.2 and 8.3 (depending on my environment)

My questions:

- what is the best way to generate an id for a new object? I want to
avoid risks of collision between what the Java app does and what the
Ruby ap does.

- when creating a new object, the id is never stored. In my current
form, I force the id to be set manually (until I can solve the previous
question). Yet, when the data is stored, I get an error from my database
saying the id is null. When I look at the code used to store, the ID
does not appear. Why not and how do I fix that?

- I have a few fields that set the modification date, and the status
(one modified, one for deleted). The database does not set the
modification date automatically. What is the preferred way to updated
it? Similar question for the modified field.

- For the delete field, I want to set the "delete" flag to TRUE instead
of physically deleting the object. What is the best way to do this?

- Finally, I am working with one object for now but I will need to do
something similar for five or six other objects. How can I scaffold all
of the above so that I have as little code to retype as possible?

Thanks,

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