search for: reset_sequences

Displaying 2 results from an estimated 2 matches for "reset_sequences".

2006 Jan 25
3
Resetting sequences in unit tests with pg
Hi all, Rails 1.0 Postgresql 8.1 Ruby 1.8.4 Is there a way to reset sequences in unit tests when loading fixture data? I came across mention of a "Fixtures.reset_sequences method here: http://api.rubyonrails.com/files/vendor/rails/activerecord/CHANGELOG.html However, when I tried to call Fixtures.reset_sequences in the setup method, I got a NoMethodError. Any ideas? Thanks, Dan
2005 Aug 23
0
Fixtures: pluraly bitten
...only reset for some of the tables I''m using. The reason? Inconsistent singularization. I won''t go so far as to say that plurals are bad, but their handling in Rails is blatant violation of the DRY principle. Fixtures has a method for resetting PostgreSQL sequences def self.reset_sequences(connection, table_names) table_names.flatten.each do |table| table_class = Inflector.classify(table.to_s) if Object.const_defined?(table_class) pk = eval("#{table_class}::primary_key") if pk == ''id'' connection.execute(...