Revision e768c976
Added by Tomáš Strachota over 9 years ago
app/models/role.rb | ||
---|---|---|
extend FriendlyId
|
||
friendly_id :name
|
||
|
||
include Parameterizable::ByIdName
|
||
|
||
# Built-in roles
|
||
BUILTIN_DEFAULT_USER = 1
|
||
BUILTIN_ANONYMOUS = 2
|
||
... | ... | |
|
||
scoped_search :on => :name, :complete_value => true
|
||
|
||
def to_param
|
||
"#{id}-#{name.parameterize}"
|
||
end
|
||
|
||
def initialize(*args)
|
||
super(*args)
|
||
self.builtin = 0
|
Also available in: Unified diff
Fixes #6710 - unicode characters in url parameters
Original methods to_param defined on resources called name.parameterize
to get rid of url-unsafe characters. This function unfortunately also
stripped off unicode characters.
Changes:
- parameterization extracted into a separate module Parameterizable
- each resource defines methods 'to_param' and 'from_param' to ensure correct search
- views updated to always use to_param when building links
- parameterization changed to id+name for resources where it wasn't safe to rely only on names
- default parameter is id