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