I was testing my models with this new library and I got:>> s.tag "warp"ActiveRecord::StatementInvalid: ERROR: inserción o actualización en la tabla «tags_stories» viola la llave foránea «tags_stories_story_id_fkey» DETAIL: La llave (story_id)=(8) no está presente en la tabla «stories». : INSERT INTO tags_stories ("tag_id", "story_id") VALUES (''3'', ''8'') from ./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:462:in `log'' from ./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:109:in `execute'' from ./script/../config/../vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:135:in `insert_record'' from ./script/../config/../vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:86:in `push_with_attributes'' from ./script/../config/../lib/taggable.rb:286:in `tag'' from ./script/../config/../lib/taggable.rb:277:in `each'' from ./script/../config/../lib/taggable.rb:277:in `tag'' from (irb):20>> s.id=> 3>> Tag.find_by_name(''warp'').id=> 8 It exchanges the story and tags IDs, but I have no idea why it does. Any suggestion? TIA, Koke -- Jorge Bernal <jbernal-OqA2i3GDl8k@public.gmane.org> Warp Networks S.L. http://www.warp.es/ [EN] http://koke.amedias.org/ [ES] http://www.amedias.org/koke
Jorge Bernal wrote:> I was testing my models with this new library and I got: >>>s.tag "warp" > > ActiveRecord::StatementInvalid: ERROR: inserción o actualización en la tabla > «tags_stories» viola la llave foránea «tags_stories_story_id_fkey» > DETAIL: La llave (story_id)=(8) no está presente en la tabla «stories». > : INSERT INTO tags_stories ("tag_id", "story_id") VALUES (''3'', ''8'') > > from ./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:462:in > `log'' > It exchanges the story and tags IDs, but I have no idea why it does.Hi Jorge, It was a bug and it''s already fixed. Please download the latest version. Cheers Demetrius -- http://dema.ruby.com.br - Rails from a .NET perspective
El Tuesday 06 September 2005 17:22, Demetrius Nunes escribió:> Hi Jorge, > > It was a bug and it''s already fixed. Please download the latest version. >I already have the last version, I downloaded it again and it''s the same file. It also has documentation, but it keeps failing :( Cheers, Koke> Cheers > Demetrius-- Jorge Bernal <jbernal-OqA2i3GDl8k@public.gmane.org> Warp Networks S.L. http://www.warp.es/ [EN] http://koke.amedias.org/ [ES] http://www.amedias.org/koke
Jorge Bernal wrote:> El Tuesday 06 September 2005 17:22, Demetrius Nunes escribió: > >>Hi Jorge, >> >>It was a bug and it''s already fixed. Please download the latest version. >> > > > I already have the last version, I downloaded it again and it''s the same file. > It also has documentation, but it keeps failing :( > > Cheers, > Koke > > >>Cheers >>Demetrius > >That´s weird. Can you post or send me your related db schema, as well as your model classes? Cheers Dema -- http://dema.ruby.com.br - Rails from a .NET perspective
El Tuesday 06 September 2005 18:28, Demetrius Nunes escribió:> That´s weird. Can you post or send me your related db schema, as well as > your model classes? >The database is on PostgreSQL, I don''t know if it''s related but I let you know :) DB schema: create table tags ( id serial, name varchar(50) unique not null, primary key(id) ); create table stories ( id serial, language integer not null default ''1'', title varchar(100), excerpt varchar(255), content text, primary key(id), foreign key(language) references languages(id) on delete cascade ); create table tags_stories ( tag_id integer not null, story_id integer not null, primary key(story_id, tag_id), foreign key(story_id) references stories(id) on delete cascade, foreign key(tag_id) references tags(id) on delete cascade ); app/models/tag.rb: class Tag < ActiveRecord::Base end app/models/story.rb: class Story < ActiveRecord::Base belongs_to :language, :foreign_key => ''language'' acts_as_taggable end> Cheers > Dema-- Jorge Bernal <jbernal-OqA2i3GDl8k@public.gmane.org> Warp Networks S.L. http://www.warp.es/ [EN] http://koke.amedias.org/ [ES] http://www.amedias.org/koke
Jorge Bernal wrote:> El Tuesday 06 September 2005 18:28, Demetrius Nunes escribió: > >>That´s weird. Can you post or send me your related db schema, as well as >>your model classes? >>Jorge, you´re right. There was a bug that was exchanging foreign keys and got fixed the wrong way. Somehow, my own tests would work either way, so I didn´t detect it. It´s already fixed. Please download it again. My apologies and thanks for spotting that. Regards, Demetrius -- http://dema.ruby.com.br - Rails from a .NET perspective
El Tuesday 06 September 2005 19:18, Demetrius Nunes escribió:> Jorge Bernal wrote: > > El Tuesday 06 September 2005 18:28, Demetrius Nunes escribió: > >>That´s weird. Can you post or send me your related db schema, as well as > >>your model classes? > > Jorge, you´re right. There was a bug that was exchanging foreign keys > and got fixed the wrong way. > > Somehow, my own tests would work either way, so I didn´t detect it. > > It´s already fixed. Please download it again. My apologies and thanks > for spotting that. >It seems to work OK. Thanks, Koke> Regards, > Demetrius-- Jorge Bernal <jbernal-OqA2i3GDl8k@public.gmane.org> Warp Networks S.L. http://www.warp.es/ [EN] http://koke.amedias.org/ [ES] http://www.amedias.org/koke