diff --git a/app/models/item.rb b/app/models/item.rb index 09d36126..ff025ad4 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -1,6 +1,8 @@ # requires item sweeper at bottom class Item < ActiveRecord::Base + include PrettyParam + SwfAssetType = 'object' has_many :closet_hangers @@ -173,15 +175,6 @@ class Item < ActiveRecord::Base } end - URL_CHAR_BLACKLIST = /[^a-z0-9\-]/i - def name_for_url - name.downcase.gsub(' ', '-').gsub(URL_CHAR_BLACKLIST, '') - end - - def to_param - "#{id}-#{name_for_url}" - end - before_create do self.sold_in_mall ||= false true diff --git a/app/models/pretty_param.rb b/app/models/pretty_param.rb new file mode 100644 index 00000000..c24bd71a --- /dev/null +++ b/app/models/pretty_param.rb @@ -0,0 +1,11 @@ +module PrettyParam + BLACKLIST = /[^a-z0-9]/i + def name_for_param + name.split(BLACKLIST).select { |word| !word.blank? }.join('-') + end + + def to_param + "#{id}-#{name_for_param}" + end +end + diff --git a/app/models/user.rb b/app/models/user.rb index 20f027b4..b83b251c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,6 @@ class User < ActiveRecord::Base + include PrettyParam + DefaultAuthServerId = 1 PreviewTopContributorsCount = 3