D
David Krmpotic
Hello,
I've been wondering about this for some time now.. Why don't any of the
following methods work: string.at/from/first/last/humanize/pluralize ?
IRB returns:
NoMethodError: undefined method `pluralize' for "something":String
You can try it yourself (also by using web IRB from here:
http://tryruby.hobix.com/)
Those methods are mentioned in "Agile Development with Rails" for
example.. you can also see people using them on Google code search.
However, they are not mentioned in documentation:
http://ruby-doc.org/core/classes/String.html
This is funny. Also.. string.to_json and string.to_yaml are mentioned in
the agile book, but don't work either.
This example doesn't go through in IRB:
# For demo purposes, create a Ruby structure with two attributes
Rating = Struct.newname, :ratings)
rating = Rating.new("Rails" , [ 10, 10, 9.5, 10 ])
# and serialize an object of that structure two ways...
puts rating.to_json #=> ["Rails", [10, 10, 9.5, 10]]
puts rating.to_yaml #=> --- !ruby/struct:Rating
name: Rails
ratings:
- 10
- 10
- 9.5
- 10
Can you help me understand all this? Thank you!
David
I've been wondering about this for some time now.. Why don't any of the
following methods work: string.at/from/first/last/humanize/pluralize ?
IRB returns:
NoMethodError: undefined method `pluralize' for "something":String
You can try it yourself (also by using web IRB from here:
http://tryruby.hobix.com/)
Those methods are mentioned in "Agile Development with Rails" for
example.. you can also see people using them on Google code search.
However, they are not mentioned in documentation:
http://ruby-doc.org/core/classes/String.html
This is funny. Also.. string.to_json and string.to_yaml are mentioned in
the agile book, but don't work either.
This example doesn't go through in IRB:
# For demo purposes, create a Ruby structure with two attributes
Rating = Struct.newname, :ratings)
rating = Rating.new("Rails" , [ 10, 10, 9.5, 10 ])
# and serialize an object of that structure two ways...
puts rating.to_json #=> ["Rails", [10, 10, 9.5, 10]]
puts rating.to_yaml #=> --- !ruby/struct:Rating
name: Rails
ratings:
- 10
- 10
- 9.5
- 10
Can you help me understand all this? Thank you!
David