Hi,
I''m trying to implement dehumanize method in Rails 3. Basically what
this post does:
http://rubyglasses.blogspot.com/2009/04/dehumanizing-rails.html
Here:
module ActiveSupport::Inflector
# does the opposite of humanize.... mostly. Basically does a
# space-substituting .underscore
def dehumanize(the_string)
result = the_string.to_s.dup
result.downcase.gsub(/ +/,''_'')
end
end
class String
def dehumanize
ActiveSupport::Inflector.dehumanize(self)
end
end
config/inflections.rb in Rails 3 says:
# Add new inflection rules using the following format
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural /^(ox)$/i, ''\1en''
end
But if change that to inflect.pluralo /^(ox)$/i, ''\1en''
It will complain with:
`block in <top (required)>'': undefined method `pluralo''
for
#<ActiveSupport::Inflector::Inflections:0x00000100d5f560>
(NoMethodError)
I''m missing something.
Cheers.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 February 2011 08:20, comopasta Gr <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> # Add new inflection rules using the following format > ActiveSupport::Inflector.inflections do |inflect| > inflect.plural /^(ox)$/i, ''\1en'' > end > > But if change that to inflect.pluralo /^(ox)$/i, ''\1en'' > It will complainplural != pluralo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote in post #983295:> On 23 February 2011 08:20, comopasta Gr <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> # Add new inflection rules using the following format >> ActiveSupport::Inflector.inflections do |inflect| >> inflect.plural /^(ox)$/i, ''\1en'' >> end >> >> But if change that to inflect.pluralo /^(ox)$/i, ''\1en'' >> It will complain > > plural != pluraloHi, do you mean that I misspelled the name? What I mean is that any new name I put there generates a method not found error. So if I write inflect.dehumanize I get: `block in <top (required)>'': undefined method `dehumanize'' for #<ActiveSupport::Inflector::Inflections:0x00000100d5f560> (NoMethodError) So apparently something else is needed other than the rule in that file (?) I wasn''t clear, sorry. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.