Rails Superheroine Challenge

Amos Shin
2 min readMay 12, 2019

--

Last time I challenged you to finish coding with Ruby. This time we’ll dive into Rails. Same challenge as last time, except you’ll have 90 minutes to finish this time (as this might be harder to finish within 60 minutes)

Here are the prompts:

You’ve just been hired by ‘Marvel Comics’ — congratulations! The production staff wants you to make a website that will allow the fans to create heroines. To do this, we need a way to keep track of all of the new heroines and powers that have been created by the fans.

Luckily, another developer has already started the job. We have a model for heroines and a model for powers. Once the database is seeded, visiting `/heroines` displays all of the heroines, and visiting `/powers` displays all of the powers. We just don’t have a way to associate heroines with powers.

We have several different powers and each can be bestowed upon **more than one heroine**. Each heroine can only have **one power**.

1. Create the associations between models. You may have to alter the current schema to get your code working.

If you’ve set up your relationships properly, you should be able to run `rake db:seed` without errors, and confirm in console that the heroines and powers have been created with the proper relations.

2. On the heroines index page, a heroine’s super name should link to that heroine’s show page.

3. The heroine show page should include the heroine’s name (eg. Kamala Khan), her super name (eg. Ms. Marvel), and her power. The power should link to the power show page.

4. The power show page should have its name and description.

5. As a visitor to the website, I should be able to create a new heroine with her name and super name.

6. The form should also allow each heroine to be created with **only one of the existing powers**.

![A form for adding a new heroine](new_heroine_form.gif)

7. Make sure no two heroines have the same super name.

# BONUS TO BE COMPLETED IF EVERYTHING ELSE IS DONE

8. Add a filter to the index view of the heroines. This will allow the visitor to search for an existing power and display all the heroines with that power on the same view page.

Good luck!

--

--