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
VillainModelwith defaults (set to null) for the following attributesidnamespeciessuperpower
- Create a Backbone Collection called
VillainCollection, and pass it the RESTfulurlfor 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
speciesof 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'ssuperpowertohatred. - Persist the change in
shredder's superpower. Validate that the change was made in the database using the Rails console.