diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/blog_post.rb | 8 | ||||
-rw-r--r-- | app/views/admin/blog/posts/_form.html.erb | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 5c0101d..a010d98 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -21,12 +21,12 @@ 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') - attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids + attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url scope :by_archive, lambda { |archive_date| where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]) @@ -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 diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb index c0467fd..abff4f2 100644 --- a/app/views/admin/blog/posts/_form.html.erb +++ b/app/views/admin/blog/posts/_form.html.erb @@ -73,6 +73,15 @@ </ul> <h3><%= t('.published_at') %></h3> <%= f.datetime_select :published_at %> + + <div class='field'> + <span class='label_with_help'> + <%= f.label :custom_url, t('.custom_url') %> + <%= refinery_help_tag t('.custom_url_help') %> + </span> + <%= f.text_field :custom_url, :class => "widest" %> + </div> + </div> <div class='hemisquare right_side'> <%= render :partial => '/seo_meta/form', :locals => {:form => f} %> |