Note: This is a "railsier" (and more succinct) version of this question, which was getting a little long.
I'm getting Rails behavior on a production server that I can't replicate on the development server. The codebases are identical save for credentials and caching settings, and both are powered by Oracle 10g databases with identical schema (but different data).
My Rails application contains a user model, which has_one registration; registration in turn has_and_belongs_to_many company_ownerships through a registration_ownerships table. Upon registering, users fill out data pertinent to all three models, including a series of checkboxes indicating what registration_ownerships might apply to their account.
On the dev server, the registration process is seamless, no matter what data is entered. On production, however, if users check off any of the company ownership fields before submitting their registration, Oracle complains about a constraint violation on the primary key of the company_ownerships table (which is a two-field key based on company_ownership_id and registration_id) and users get the standard Rails 500 error screen. In every case, I've verified that no conflicting record on these two fields exists in the production database, so I don't know why the constraint is getting violated.
To further confuse things, if a user registers without listing any ownerships and later goes back and modifies their account to reflect ownership data (which is done through the same interface), the application happily complies with their request and Oracle is well-behaved (this is both on production and dev).
I've spent the past couple days trying to figure out what might be causing this problem and am reaching the end of my wits. Any advice would be greatly appreciated!
UPDATE 4/15/10: I've just noticed something that might be helpful. I tried registering identical accounts on dev and production and intentionally left the "phone" field blank, which is a required field. On dev, I got back the following message:
1 error prohibited this registration from being saved
There were problems with the following fields:
- Phone can't be blank
However, on production, I get this:
2 errors prohibited this registration from being saved
There were problems with the following fields:
- Phone can't be blank
- Phone can't be blank
My guess is that this is directly tied to the violated constraint on production--maybe as part of a commit, the field is inserted once, and then inserted again but violates the constraint the second time and then rolls back the entire transaction, removing all evidence of the initial insert. Any ideas about what might be causing this sort of behavior, either on the Rails side or on the Oracle side?