September 2013
Intermediate to advanced
112 pages
2h 42m
English
Let’s start with the models. The model code should be independent of any other classes, so filling them in is usually a good place to start. Resist the temptation to make explicit references to your views or controllers!
First up are the Color objects. The Colr API returns its colors as JSON objects in the following form:
| | { |
| | "timestamp": 1285886579, |
| | "hex": "ff00ff", |
| | "id": 3976, |
| | "tags": [{ |
| | "timestamp": 1108110851, |
| | "id": 2583, |
| | "name": "fuchsia" |
| | }] |
| | } |
Right away, it looks like we need timestamp, hex, id, and tags properties. In particular, tags represents a has-many relationship with Tag objects.
Let’s get down to business. Open color.rb and start filling it in with our ...
Read now
Unlock full access