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?
> So weird. I run the migration but it does nothing to db/schema.rb:
>
> add_index "snippets", ["name", "site_id"], :name =>
> "index_snippets_on_name_and_site_id", :unique => true
> add_index "snippets", ["name"], :name => "name", :unique => true
>
> Here's the exact migration:
>
> $ cat db/migrate/004_migration4.rb
> class AddSiteIdIndex < ActiveRecord::Migration
> def self.up
> remove_index :snippets, :name
> end
It's probably the named index, and me being too hasty. Try
remove_index :snippets, :name => 'name'
will
Snippet:
name:
message:
'Name wurde schon verwendet'
scope:
site_id
in config/vhost.yml
should do the trick ...
--
DI Edmund Haselwanter, edm...@haselwanter.com, http://edmund.haselwanter.com/
http://www.iteh.at | http://facebook.com/iTeh.solutions | http://at.linkedin.com/in/haselwanteredmund
> Below is the migration that finally did the trick! There wasn't really
> a need to have an index on the name attribute anyways since it'll
> always require the site_id.
The uniqueness of a field in rails is a programatic constrain in ruby, not a constrain on the database layer.
The vhost.yml file takes care of this and evaluates this.
>
> I'm still interested in Haselwanter's note about how the config/
> vhost.yml file alone should have taken care of this. Am I missing
> something obvious here?
yes:
There is some code in the rake radiant:extensions:vhost:apply_site_scoping which alters special index
behaviour. At least for snippets it should just work
https://github.com/saturnflyer/radiant-vhost-extension/blob/master/lib/tasks/add_site_columns.rb#L45
--
DI Edmund Haselwanter, edm...@haselwanter.com, http://edmund.haselwanter.com/