forked from OpenNeo/impress
Matchu
99f5cd717f
The models folder is a bit confusingly large, these are more mixins and kinda clutter it. Push them off into `lib`, I think! I think they used to be in models mainly because Rails used to handle `lib` differently with autoloading, and it made for a worse dev experience. Now it's all the same, though!
11 lines
197 B
Ruby
11 lines
197 B
Ruby
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
|
|
|