ruby - Rails Trouble creating model instance with one to many relationship -


I think there are so many places where my design can be screwed on it though I have limited experience with rail . This postage is happening in Rails 2.3.2 with 8.3.

We have two tables in our DB, one called " Survey " and another one called " survey_timpoint ". A survey can be number multiple times, so in the survey_timepoint table, there is a column called " survey_id " which has a FK obligation.

I also think that I should mention that the tables were not made with rail migration, although they adhere to the railing naming convention, I suspect that AR feared a hurdle on that column. It is not and how to handle this situation, it does not know.

I have in my rail model:

  has_many:        

  s = Survey. New S.SurviTimPoint Push SurveyTimepoint.new s.save!  

I get:

  ActiveRecord :: Statement invalid: PGError: Error: Enter or update the table on "survey_timpoint" violates foreign key constraints "Survey_timepoints_fk" Description: Key (Survey_ID) = (59) The table is not present in "Survey"  

I agree that if I delete the code that is survey_timepoint .survey_id happens to be working properly It seems that I should not even be doing what I am different Gekts am being trapped for creating separate and wrap the whole process a transaction? It seems that it is non-railable

you want to send a SQL command, which you can send . It seems that this is adding survey_timepoint records before the survey record, note that you are already working with two database changes & mdash; Surveys and Survey_River & mdash; You should use the transaction

before adding tilepoint to s.save! can fix the problem immediately (and then call it again) My knowledge of rail efficiency is not enough to know whether there is another "rail" method to do that in the transaction Wrap.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -