Friendly ID 4 Using scoped module

筅森魡賤 提交于 2019-12-05 18:30:02

If you are currently indexing your pages on the slug field with something like this:

add_index :page, :slug, :unique => true

then you might want to swap that for an index on both the slug and the region:

remove_index :page, :slug
add_index :page, [:slug, :region_id], :unique => true

The documentation describes how to start using :history and :scoped together in FriendlyId 5, maybe that could give you some ideas on how to solve it in your case: http://rubydoc.info/github/norman/friendly_id/master/file/README.md#Upgrading_from_FriendlyId_4_0


Or, you could just remove the uniqueness constraint, as I now see that you have replied to my original comment. :)

remove_index :page, :slug
add_index :page, :slug # no :unique here
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!