Art Of Programming

musings by Dmytrii Nagirniak

Stuff Learned Today - Ruby and Rails

  1. Ruby ignores underscores in numbers, so you can write 53782156 as 53_782_156 which is much nicer.
  2. Suggested localisation for Formtastic’s collections. Not sure whether it is important as it is still pretty easy to workaround.
  3. To use all the ActiveSupport (v3), do require ‘active_support/all’ (note the underscore!).
  4. We can add methods to associations by opening a block and (but scopes are much cleaner on the other end of association class).
  5. Testing “access denied” and “requires user” is easier with custom matchers.
  6. Rails URL helpers are not available in custom matchers for some reason.
  7. Shoulda’s RSpec matcher validates_presence_of does not work with non-persistent models.
  8. Rails params hash has string keys, not symbols. Got issues with it when relying on keys being symbols.

Comments