Hi Donald,

Do you really want to use name as index field in the database? The most
usual case is not to set the index, so Hobo/Rails use the field "id".

Then you only need to use ":unique", instead of ":unique => true" to
make Hobo validate the field as unique.

Another option is to go the Rails way with:

  validates :name, :presence => true, :uniqueness => true

Regards,
Ignacio

El 30/09/13 01:37, Donald Ziesig escribió:
> Hi All!
> 
> I have another wierdness.  Using a "plain vanilla" resource "fixup" with
> the following code in the model:
> 
>   fields do
>     name        :string, :unique => true, :index => true
>   end
> 
> A long time ago, I used similar code and hobo presented a "Record can't
> be saved ... duplicate" error box (which is what I expected this time).
> 
> Unfortunately, I am now getting:
> 
> PG::UniqueViolation: ERROR:  duplicate key value violates unique
> constraint "index_fixups_on_name"
> DETAIL:  Key (name)=(2ND) already exists.
> : INSERT INTO "fixups" ("action", "name", "replacement") VALUES ($1, $2,
> $3) RETURNING "id"
> 
> 
> The reason for the unique flag is that the app may not contain duplicate
> names, but the names are generated automatically and can easily contain
> dups.  I can work around this (it is an exception that I expect and
> which I will ignore).
> 
> When I am testing using the hobo gui, I expect the warning rather than
> the crash.
> 
> Ideas anyone?
> 
> Don Ziesig
> 

-- 
Ignacio Huerta Arteche
http://www.ihuerta.net
Teléfono: 0034 645 70 77 35
Email realizado con software libre

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to