diff options
author | Kyle Wilkinson <kai@wikyd.org> | 2011-06-16 22:24:49 -0700 |
---|---|---|
committer | Kyle Wilkinson <kai@wikyd.org> | 2011-06-16 22:52:21 -0700 |
commit | 9320a6a608f097c8fc316b9c2a1e2a3f0bc21afb (patch) | |
tree | b8d126fa41e04af807f949a9a8b770b9357fec0a | |
parent | 07a1a81b95ff4be4b4a861496af6af6afbdf8923 (diff) | |
download | refinerycms-blog-9320a6a608f097c8fc316b9c2a1e2a3f0bc21afb.tar.gz refinerycms-blog-9320a6a608f097c8fc316b9c2a1e2a3f0bc21afb.tar.bz2 refinerycms-blog-9320a6a608f097c8fc316b9c2a1e2a3f0bc21afb.zip |
Add logic to allow users to override the url for a post from just a title.
-rw-r--r-- | app/models/blog_post.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 5c0101d..914e112 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -21,7 +21,7 @@ class BlogPost < ActiveRecord::Base validates :title, :presence => true, :uniqueness => true validates :body, :presence => true - has_friendly_id :title, :use_slug => true, + has_friendly_id :friendly_id_source, :use_slug => true, :default_locale => (::Refinery::I18n.default_frontend_locale rescue :en), :approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => 'blog'), :strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => 'blog') @@ -61,6 +61,10 @@ class BlogPost < ActiveRecord::Base }.compact end + def friendly_id_source + custom_url.present? ? custom_url : title + end + class << self def next current_record self.send(:with_exclusive_scope) do |