Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Francis Hwang
RE: Getting objId for the commited object [ reply ]  
2004-09-08 03:48
Though I should note that the DomainObject#pkId is just a normal method, so you should be able to use

alias_method :pkId, :objId
alias_method :pkId=, :objId=

if you absolutely can't stand using "pkId".

I have not tried this out myself, but off the top of my head I can't imagine why it wouldn't work.

By: Dima Sabanin
RE: Getting objId for the commited object [ reply ]  
2004-09-08 03:48
Oh, now I see. Thanks for quick help :)

By: Francis Hwang
RE: Getting objId for the commited object [ reply ]  
2004-09-08 03:39
DomainObject.sqlPrimaryKeyName only affects what field is used in the MySQL. When you're manipulating in Ruby, it's always "pkId".

By: Dima Sabanin
RE: Getting objId for the commited object [ reply ]  
2004-09-08 03:29
Well, I've redefined DomainObject.sqlPrimaryKeyName to return 'objId', and I get
NoMethodError: undefined method `objId' for #<TestObj:0x4058113c>
Btw, I'm trying to use 'objId' because I don't like 'pkId' name for indexes.

By: Francis Hwang
RE: Getting objId for the commited object [ reply ]  
2004-09-08 03:07
Yeah, that's just how it works. When you do an insert it gets the primary key automatically.

FYI, once you start using Lafcadio 0.4.0, it's "pkId", not "objId".

By: Dima Sabanin
Getting objId for the commited object [ reply ]  
2004-09-07 05:59
I need to get the objId that was given to the object I've just committed, is it possible?
I.e. something like this:
test = TestObj.new( 'text' => 'bla')
test.commit
p test.objId # => 23