Hi,
this one has been finally put to bed!!
–
Regards
Andrew
Hi,
this one has been finally put to bed!!
–
Regards
Andrew
On 3/1/07, Andrew M. [email protected] wrote:
Hi,
this one has been finally put to bed!!
How?
Curious,
jeremy
–
Hi,
How?
the process is as follows (i’m using pgRails by the way):
page
ActiveRecord::Base.pluralize_table_names = false
Note: You are looking for:
module ConnectionAdapters
…
class PostgreSQLAdapter < AbstractAdapter
then place the following code:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def prefetch_primary_key?(table_name = nil)
true
end
def next_sequence_value(sequence_name)
Integer(select_value("SELECT nextval('#{sequence_name}')"))
end
This def next_sequence_value, alternatively, would be place in your
MySQL adapter file if you were using MySQL!!
#def next_sequence_value(sequence_name)
# sql = “UPDATE #{sequence_name} SET Id=LAST_INSERT_ID(Id+1);”
# update(sql, “#{sequence_name} Update”)
# select_value(“SELECT Id from #{ sequence_name}”,‘Id’)
#end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: You are looking to replace/comment out def reset_sequence_name
then replace that block with this:
def reset_sequence_name
"#{table_name}_seq"
end
class Usertbl < ActiveRecord::Base
set_primary_key “your_tbl_id”
set_sequence_name “your_db_sequence” #Note that your dB sequence
will
have to have the format of somename_seq
end
That’s it, ALL DONE!!
Hope that helps
–
Regards
Andrew
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs