parameterize user params like items, plus a cleaner parameterization scheme
This commit is contained in:
parent
c592459d02
commit
033e71e9bf
3 changed files with 15 additions and 9 deletions
|
@ -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
|
||||
|
|
11
app/models/pretty_param.rb
Normal file
11
app/models/pretty_param.rb
Normal file
|
@ -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
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
class User < ActiveRecord::Base
|
||||
include PrettyParam
|
||||
|
||||
DefaultAuthServerId = 1
|
||||
PreviewTopContributorsCount = 3
|
||||
|
||||
|
|
Loading…
Reference in a new issue