Skip to content

Commit

Permalink
Separate collection of friendly id options out into their own class.
Browse files Browse the repository at this point in the history
  • Loading branch information
awagener committed Nov 26, 2013
1 parent ca09216 commit 1b4a23f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pages/app/models/refinery/page.rb
Expand Up @@ -18,6 +18,22 @@ def self.seo_fields
end
end

class FriendlyIdOptions
def self.options
# Docs for friendly_id http://github.com/norman/friendly_id
friendly_id_options = {
use: [:reserved],
reserved_words: %w(index new session login logout users refinery admin images wymiframe)
}
if ::Refinery::Pages.scope_slug_by_parent
friendly_id_options[:use] << :scoped
friendly_id_options.merge!(scope: :parent)
end
friendly_id_options[:use] << :globalize
friendly_id_options
end
end

# Delegate SEO Attributes to globalize translation
delegate(*(Translation.seo_fields << {:to => :translation}))

Expand All @@ -33,18 +49,7 @@ def self.seo_fields
# rather than :delete_all we want :destroy
acts_as_nested_set :dependent => :destroy

# Docs for friendly_id http://github.com/norman/friendly_id
friendly_id_options = {
use: [:reserved],
reserved_words: %w(index new session login logout users refinery admin images wymiframe)
}
if ::Refinery::Pages.scope_slug_by_parent
friendly_id_options[:use] << :scoped
friendly_id_options.merge!(scope: :parent)
end
friendly_id_options[:use] << :globalize

friendly_id :menu_title_or_title, friendly_id_options
friendly_id :menu_title_or_title, FriendlyIdOptions.options

has_many :parts, -> {
scope = order('position ASC')
Expand Down

0 comments on commit 1b4a23f

Please sign in to comment.