This works, but looks a little bit ugly:
s = :shop
s.to_s.pluralize.to_sym # => :shops
Is there a nicer way to pluralize a Symbol
?
You can pluralize a String
, which represents actual text. Symbol
s are a bit more abstract.
So, by definition, no. However, perhaps you could open up the Symbol class definition and add:
class Symbol
def pluralize
to_s.pluralize.to_sym
end
end
Then, you can just call:
:shop.pluralize # => :shops