I have a table as such: table1_id|table2_id No id, primary key, sequence, etc. When I try to create/new a record, I get this: table21.create(:table1_id=>1, :table2_id=>2) PGError: ERROR: relation "table12_id_seq" does not exist : SELECT currval(''table12_id_seq'') Does Rails really expect all tables to have id sequences, or is there a way around this? thanks csn __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
CSN, Is there a reason you actively don''t want to have a primary key in your join tables? Even in cases where you only expect a one to one relationship (example: husband to wife) it doesn''t hurt to have a primary key, and if your assumptions don''t hold true (say you take on some polygamous users) you''ll have a mess to clean up. pt. On 12/11/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I have a table as such: > > table1_id|table2_id > > No id, primary key, sequence, etc. When I try to > create/new a record, I get this: > > table21.create(:table1_id=>1, :table2_id=>2) > > PGError: ERROR: relation "table12_id_seq" does not > exist > : SELECT currval(''table12_id_seq'') > > Does Rails really expect all tables to have id > sequences, or is there a way around this? > > thanks > csn > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Parker Thompson http://www.parkert.com/ 510.541.0125
A mess? Dealing with join table data is pretty simple. Primary keys for them are useless IMO. My last two questions are moot - HABTM is pretty slick. Got everything working :). csn --- Parker Thompson <parkert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> CSN, > > Is there a reason you actively don''t want to have a > primary key in > your join tables? Even in cases where you only > expect a one to one > relationship (example: husband to wife) it doesn''t > hurt to have a > primary key, and if your assumptions don''t hold true > (say you take on > some polygamous users) you''ll have a mess to clean > up. > > pt. > > On 12/11/05, CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > wrote: > > I have a table as such: > > > > table1_id|table2_id > > > > No id, primary key, sequence, etc. When I try to > > create/new a record, I get this: > > > > table21.create(:table1_id=>1, :table2_id=>2) > > > > PGError: ERROR: relation "table12_id_seq" does > not > > exist > > : SELECT currval(''table12_id_seq'') > > > > Does Rails really expect all tables to have id > > sequences, or is there a way around this? > > > > thanks > > csn > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Parker Thompson > http://www.parkert.com/ > 510.541.0125 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Dear Sir, I''ve got the same troubles as you on creating new records on tables without sequences. Could you, please, tell me that is the solution that you''ve found? Thank you in advance. ag CSN wrote:> Got everything working :). > > csn-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---