Semicolon & Sons
X
About
Contact & Support
Code Diary
Episodes
Blog
Subscribe
Sign in
Semicolon & Sons
About
Screencasts
Code Diary
Blog
Contact & Support
Subscribe
Sign In
Rails Code Diary Entries
This is part of the Semicolon&Sons
Code Diary
- consisting of lessons learned on the job.
After commit vs after save
Alway set inverse of to get two way bindings
Always restart the server fully after a database migration
Avoid first or create when working with attributes that are not unique per record
Careful with to JSON
Define instance variables in controllers before any branching
Delegate does not create setter methods
Delete webpack relics if code changes are not picked up
Do your DB calls in the controller not your views
Dots cause issues in rails urls
Empty select box gives empty string not nil
How to create an association without has many and friends
If state is not getting updated look for rollback in your SQL logs
If you set form state explicitly it will be lost at validation stage
Initialization code should avoid overwriting parameters explicitly passed in
Merge does not handle multiple in clauses
Prefer url to PATH for url helpers
Select statements that do not include the id column will break joins
Store session keys as strings not symbols
Use on load hooks then backtracing for debugging
Validate associations within contexts but not alone
Validators run even if nil
You need after add or after remove callbacks to take action on has any belongs to many set modifications