For example I want to add my own has_many_stuff in ActiveRecords. So I make something like
module Stuff
def has_many_stuff name
has_many name
stuff_model = name.to_class #What I shoud do here?
...
end
end
The problem is there are can be different cases and singular or plural forms in the name. But rails somehow works with it. So how?
See http://apidock.com/rails/String. There’s a lot functions which might help you solve your problem. For instance,
String#pluralizeandString#pluralizemight help with plural. After generating the string which you need you can convert it to symbol usingString#to_sym.