On 14 Feb 2011, at 05:46, craayzie wrote:

> So this appears to be simple issue of the Snippets model validation
> not being updated. I know the proper way to do this is to create an
> ActiveRecord migration but just to see it work I hand-edited vendor/
> radiant/app/models/snippet.rb
> - validates_uniqueness_of :name, :scope
> + validates_uniqueness_of :name, :scope => :site_id
> I then ran 'rake db:migrate' but nothing changed? Did I miss a step?

Slight muddle there: migrations change the database columns. Validations are 
applied in the model before the object is saved to the database.

In the case of Snippets you have both kinds: there's a uniqueness constraint in 
the database which is supported by a validates_uniqueness call in the model 
class so that we can return advisory messages rather than just throwing errors.

I don't know what the current situation is with the vhost extension but your 
fix to the validates_uniqueness call is right and you can remove the uniqueness 
constraint from the database with this migration:

        remove_index :snippets, :name

You'll find similar validations on Layout and User but perhaps those won't 



Reply via email to