Advanced ActiveRecord Querying - belongs_to Associations

This topic is for the Querying belongs_to Associations exercise in the Advanced ActiveRecord Querying trail. Post any questions, comments, or pointers you have to share with other Upcase subscribers.

NB: These exercise require the PostgreSQL database to be installed.

If you’re using OSX, the easiest way is to install Afterwards, you should follow these instructions ensure that bin/setup can find the command-line tools in order to create the required database(s).

1 Like

I felt like the first video did not sufficiently prepare me for the last spec of this exercise. Most of that seems to be covered in the video after the exercize, almost making it feel like some of this is out of order. The spec I refer to is alphabetically_by_region_and_location and the video that better seems to prepare for it is the has_many one: Querying has_many Associations | Online Video Tutorial by thoughtbot


Very helpful to know–thank you!

Yes I agree It’s a little bit tricky without having seen the has_many episode

Hi what about when using Ubuntu 14.04 , I have PostgreSQL set up already, so after cloning when run bin/setup I get the below error, do i need to set up a database.yml in my case , it seem createdb is failing password authentication, see error

fe_sendauth: no password supplied (PG::ConnectionBad)

You might need to add your PostgreSQL username and password to in spec_helper.rb

1 Like

Thanks solved !!

I have to say, the description on the second spec could do with further clarity, either in a comment or in rewriting line 23.

Is the object that we first order people by their location’s regions name alphabetically, then only in the case of an alphabetical ‘tie’ (say two people are region2) we alphabetize them according to their location’s name, then only in the case of a double-tie (say multiple people with location3 and region2) we alphabetize them on their personal name?

1 Like