You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using UUID type for database table id columns, the behavior should be the same as using integer type for id columns. Note that as of 2020-08-26, to use CMS required ActiveStorage, but ActiveStorage does not handle UUIDs with the default migration, so ActiveStorage's migration must be edited (to allow polymorphic entity associations with UUID columns).
Actual behavior
Instead, CMS gives this error when page#create is attempted:
PG::UndefinedFunction: ERROR: operator does not exist: uuid = integer LINE 1: ...s_categorizations" ON "comfy_cms_categories"."id" = "comfy_c... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts.```
### Steps to reproduce
Recreate with new Rails app but use UUID for ID column:
$ rails new cms-test
Add Postgres gem and use postgres.
$ cat > config/initializers/generators.rb
Rails.application.config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
end
$ rails webpacker:install
$ rails active_storage:install
We use UUIDs, so ActiveStorage requires polymorphic ids to be UUIDs:
$ diff db/migrate/create_active_storage… default
4c4
< create_table :active_storage_blobs do |t|
create_table :active_storage_blobs, id: :uuid do |t|
16c16
< create_table :active_storage_attachments do |t|
Expected behavior
When using UUID type for database table id columns, the behavior should be the same as using integer type for id columns. Note that as of 2020-08-26, to use CMS required ActiveStorage, but ActiveStorage does not handle UUIDs with the default migration, so ActiveStorage's migration must be edited (to allow polymorphic entity associations with UUID columns).
Actual behavior
Instead, CMS gives this error when page#create is attempted:
$ rails new cms-test
Add Postgres gem and use postgres.
$ cat > config/initializers/generators.rb
Rails.application.config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
end
$ rails webpacker:install
$ rails active_storage:install
We use UUIDs, so ActiveStorage requires polymorphic ids to be UUIDs:
$ diff db/migrate/create_active_storage… default
4c4
< create_table :active_storage_blobs do |t|
Same for CMS:
gem "comfortable_mexican_sofa", "~> 2.0.0"
bundle install
rails generate comfy:cms
Update the CMS migration to use UUIDs (see attached).
20200827044850_create_active_storage_tables.active_storage.rb.txt
20200827045455_create_cms.rb.txt
rake db:migrate
Create a site and see a URL like (it works):
http://localhost:3001/admin/sites/95eb4f68-5115-45e3-917b-1aa5bcfa7ffc/layouts/new
Create a layout (it works).
But Page->Create gives the above error.
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
gem "comfortable_mexican_sofa", "~> 2.0.0"
ruby '2.6.3'
The text was updated successfully, but these errors were encountered: