1
0
Fork 1
impress/lib/pretty_param.rb
Matchu 99f5cd717f Move some model mixins to lib/
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!
2023-12-05 14:55:31 -08:00

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