Joined September 2012
·

Matt Huggins

Web & Mobile Developer
·
Carteret, NJ
·
·
·

Posted to Make tap{} return anything over 1 year ago

One of the things I like about Ruby is how elegantly code can be written, specifically with regards to it reading like a sentence. I would steer clear of this personally, as it's pretty confusing not only for the lack of readability of the line in general, but also because it is contradicts the expected patterns and usage that come with the tap method.

Tested it in my default browser on Android 4.1.1 (Samsung Galaxy Nexus). Every click on the fast-button (or fast-link) resulted in two submissions instead of one.

An even better way (in my opinion) is to use an interceptor. Check out the "Interceptors" section of the ASCIIcast here: http://railscasts.com/episodes/206-action-mailer-in-rails-3?view=asciicast

Posted to AssociationCountValidator over 1 year ago

I had a similar question I posted on StackOverflow last year. I included my own implementation there: http://stackoverflow.com/questions/5932509/rails-validating-at-least-one-habtm-relationship

Yours definitely looks more concise, and I see it takes into account records that are marked for deletion, which mine does not.

Achievements
156 Karma
4,263 Total ProTip Views