You just learned some of the incredible magic and utility of Backbone Collections. Now it's your turn to put them to practical use.
- Create a Backbone Model called
VillainModel
- Provide the
VillainModel
with defaults (set to null) for the following attributesid
name
species
superpower
- Create a Backbone Collection called
VillainCollection
, and pass it the RESTfulurl
for appropriate for villains, as well as the appropriatemodel
. - Instantiate a
VillainCollection
, and use.fetch()
to breathe sweet, sweet data into it. - Now that your VillainCollection has 4 models within it, retrieve the villain model with id of 4 and save it to a variable called
rocksteady
. - Awesome, now retrieve the
species
of the villain model with id of 2. Save it in a variable calledspeciesOfKrang
. - Now retrieve the villain model with id of 1 to a variable called
shredder
. - Set
shredder
'ssuperpower
tohatred
. - Persist the change in
shredder
's superpower. Validate that the change was made in the database using the Rails console.