13 Apr '13, 2pm

@andrzejkrzywda

Calling Methods on Potential Nil Objects in Rails By Raymond Law November 2, 2010 in rails Rails adds a pretty cool Object#try method. From Rails doc: try(method, *args, &block) This Invokes the method identified by the symbol method, passing it any arguments and/or the block specified, just like the regular Ruby Object#send does. Unlike that method however, a NoMethodError exception will not be raised and nil will be returned instead, if the receiving object is a nil object or NilClass. This is how you use it: >> "Don'tRepeatYourselfs ".try(:underscore).try(:capitalize).try(:chop!).try(:chop!) => "Don't_repeat_yourself" >> nil.try(:underscore).try(:capitalize).try(:chop!).try(:chop!) => nil You can see it is not so DRY if you want to chain a lot of methods together, as is commonly the case in a Rails app. Inspired by RSpec’s stub_chain method, I wrote a little try_chain m...

Full article: http://www.intridea.com/blog/2010/11/2/calling-methods-on...

Tweets

Best practices for open sourcing your rails app...

railsforum.com 13 Apr '13, 3pm

Topic: Best practices for open sourcing your rails app and using git I want to: * Use git as my version control * Work in ...

"If you gaze into nil, nil gazes also into you"

robots.thoughtbot.com 04 Apr '13, 8pm

The problem with nil is that it’s hard to know when to expect it. As a developer coming onto this project, or as a develop...

Modifying the order of Datetime picker in Rails

api.rubyonrails.org 16 Apr '13, 5am

:use_month_numbers - Set to true if you want to use month numbers rather than month names (e.g. "2" instead of "February")...