diff options
author | Uģis Ozols <ugis.ozolss@gmail.com> | 2014-02-03 09:50:29 +0200 |
---|---|---|
committer | Uģis Ozols <ugis.ozolss@gmail.com> | 2014-02-03 09:50:29 +0200 |
commit | 01ff510bf009b6e7ad573846fdb5fb284fb08eed (patch) | |
tree | 92f8f18d7abe3c79791772e5e06a6e050e9bf5c0 /app | |
parent | c3b666e8730ffdc07dee5c6604ba8b109c320e2b (diff) | |
download | refinerycms-blog-01ff510bf009b6e7ad573846fdb5fb284fb08eed.tar.gz refinerycms-blog-01ff510bf009b6e7ad573846fdb5fb284fb08eed.tar.bz2 refinerycms-blog-01ff510bf009b6e7ad573846fdb5fb284fb08eed.zip |
Tell friendly_id to regenerate slug if title has changed.
This is due to change in friendly_id 5.0.x where it doesn’t regenerate
slug when record is updated.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/refinery/blog/post.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index 005ec29..f80a939 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -32,6 +32,12 @@ module Refinery is_seo_meta end + # If custom_url or title changes tell friendly_id to regenerate slug when + # saving record + def should_generate_new_friendly_id? + custom_url_changed? || title_changed? + end + # Delegate SEO Attributes to globalize translation seo_fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten delegate(*(seo_fields << {:to => :translation})) |