[Nitro] Og create method

Matthew B Gardner weather at speakeasy.net
Mon Aug 20 01:00:37 EDT 2007


Hello -

On Sunday 19 August 2007 19:10, Matthew B Gardner wrote:
> I'm getting a database error when using Class#create -- this is an example
> of the error:
>
> ERROR: DB error Duplicate entry '6' for key 1, [INSERT INTO ogcharacter
> (`oid`, `aliases`, `name`, `account_oid`) VALUES (6, '--- []\n\n',
> 'Tester', 4)]
>
> The code is:
>
> self.character = Character.create msg.capitalize, self
>
> This problem doesn't occur if I use:
>
> self.character = Character.new msg.capitalize, self
> self.character.save!
>
> I'm guessing that the first code is trying to insert itself twice? Am I
> doing something wrong w/ #create?
>
> Thanks for any help,
> Matt

It seems to be that line calling #create, mixed with this initialization:

belongs_to :account, Account

class Character
	def initialize(name = nil, acc = nil)
		super(name)
		self.account = acc # this is what's producing the error
	end
end


Hopefully that helps.
-Matt


More information about the Nitro-general mailing list