class User < ActiveRecord::Base
has_one :last_entrie
has_one :address_book
has_and_belongs_to_many :subjects
has_one :user_detail
has_and_belongs_to_many :subjects
end
class Subject < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :subject_group
end
RuntimeError: ERROR C42P01 Mrelation “subjects_users_id_seq” does not
exist Fnamespace.c L200 RRangeVarGetRelid: SELECT currval
(‘subjects_users_id_seq’)
You’re using postgresql.
It uses a ‘serial’ field for each primary key. When it inserts a new
row, it pulls the next ‘id’ value from something called a sequence
(basically,
a counter).
For some reason, the subjects_users_id_seq sequence isn’t there
any more.
You can recreate it - try ‘\h create sequence’ from inside psql.
If you have existing data in subjects_users, you need to make sure
the sequence starts with a number 1 higher than the current highest
value
in the ‘id’ field of subjects_users.
C:\Documents and Settings\Will\My
Documents\src\mm\web\cgi-bin>processBounces.rb
Connection Test Successful - Connected To The Database
Parsing Logfile Finished
Processing Bounces…
select id, bounce from sql_languages where
email=‘[email protected]’;
c:/ruby/lib/ruby/site_ruby/1.8/DBD/Pg/Pg.rb:640:in execute': ERROR C42P01 Mrelation "sql_languages" does not exist Fnamespace.c L201 RRangeVa rGetRelid (DBI::ProgrammingError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:617:inexecute’
from C:/Documents and Settings/Will/My
Documents/src/mm/web/cgi-bin/proc
essBounces.rb:84:in updateBounceCount' from C:/Documents and Settings/Will/My Documents/src/mm/web/cgi-bin/proc essBounces.rb:79:inupdateBounceCount’
from C:/Documents and Settings/Will/My
Documents/src/mm/web/cgi-bin/proc
essBounces.rb:144
from C:/Documents and Settings/Will/My
Documents/src/mm/web/cgi-bin/proc
essBounces.rb:142
Roughly the same issue, but it doesn’t seem to be an issue with the
serial… any ideas?
The code is as follows:
data_sources.each do |table_name|
email_address = email_address.downcase
selectQry = “select id, bounce from “+table_name+” where
email=’”+email_address+"’;"
sth = dbh.prepare(selectQry)
sth.execute
while rows = sth.fetch do
printf rows[0], rows[1],"\n"
end
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.