Active Associations
October 22, 2020Determine all the associations for your ActiveRecord model, no matter how sprawling.
Determine all the associations for your ActiveRecord model, no matter how sprawling.
Ruby monkeypatching is a dangerous, but necessary tool. It is convenient to add new behaviours to existing classes, or to replace existing…
You may believe that , , and are fairly equivalent: But, beware of in Rails! and are largely equivalent, but issues an additional query…
You can mimic the end-user’s UI experience accurately enough by running application code locally, but what about the backend? Once your code…
Another brilliant Rails troubleshooting technique I have recently added to my toolbox is as an add-on to . 1. Add and to the development…
I am working on upgrading an application from Rails 3.0 to Rails 3.2. While the numbers tell you it is a minor version change, there are…
Single table inheritance (STI) is a way to emulate object-oriented inheritance in a relational database by storing multiple object types in…
“It is impossible to create an abstraction unknowingly or by accident,” says Sandi Metz in Practical Object Oriented Design in Ruby. An…
I was recently fixing a failing test and discovered that Ruby and Rails implement and in confusing and occasionally opposite ways. In…
I have once more been working my way through Sandi Metz’ Practical Object-oriented Design in Ruby (POODR) for a few weeks, and developed a…
I am building an application that uses several nested attributes: Users have many Goals (Goals belongto Users), and Goals have many Hours…
I have been building a new project and getting creative with views. I am working with bootstrap and jquery to develop tabbed displays, and…
I am between computers at the moment, and I really really miss my OSX development environment. Dependency installation is so smooth and…
What is Mass Assignment? Mass assignment is using a ruby-esque shortcut to interact with models: This is NOT mass assignment. Each param is…
1. Write a failing test Use the failures to drive development: 2. No Route Add one to /config/routes.rb: 3.No Controller Add one to…
Following along with Rails tutorial by Michael Hartl, I built a sample app with a simple database, linking users to microposts in a twitter…
My page wouldn’t flash the user. Trundling along the Hartl railstutorial, I needed to write some logic to allow a user to update their…