Today I Learned

TIL, 2017-02-21

  • Remember array.include?(element) to check if an array includes an element.
  • When checking if a key exists, do hash.key?(key), not hash[key] because if key is nil, this will not populate the return.
  • Updating stuff–be more stringent than normal, all params must be correct before an update is allowed. All params meaning that the params’ keys should all be editable attributes.
  • Don’t be shy to create new errors, they are all catchable in the controller, anyway. This might actually allow you to not write conditionals in the controller, if you guarantee that service errors, auth errors, AR errors, etc. will get caught at some point.
  • Not sure if %i{key1 key2} is something I like yet.

This project is maintained by daryllxd