GithubHelp home page GithubHelp logo

dkennell / sinatra-nested-forms-lab-superheros-v-000 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-students/sinatra-nested-forms-lab-superheros-v-000

0.0 0.0 0.0 48 KB

License: Other

Ruby 72.27% HTML 27.73%

sinatra-nested-forms-lab-superheros-v-000's Introduction

Sinatra Nested Forms Lab: Superheroes!

Overview

In this lab, you'll practice building nested forms in Sinatra for creating teams of superheroes. No database is required, but feel free to add persistence after you have successfully completed the instructions below.

Instructions

Make a form

  1. Create a route that responds to a GET request at /.
  2. Create a view with a form and render it in the GET / route.
  3. The form should have fields for the name of a superhero team and their motto.
  4. There should be form inputs for each of the three superhero member's name, power, and bio.

It should look something like this:

super_hero.erb

Handle form submission

  1. Create a route that responds to a POST request at /teams
  2. Have the form send a POST request to this route.
  3. Upon submission, render a template that displays the submitted team data and each member's data.

Final Output

Your params should be nested. For example, in order to see all the superheroes for the team you just created you would enter:

params["team"]["members"]

If you wanted to access the first superhero's name, you would enter:

params["team"]["members"][0]["name"]

When you post to this form you should render a page that displays the name of the team and each member of the team, along with their name, super power and bio.

Your view should display something like this:

team.erb

Deliverables

Pass the tests! You'll notice in super_sinatra_spec.rb in theit submits the form test for 'POST /teams', we use the Capybara method fill_in:

fill_in("member1_name", :with => "Amanda")
fill_in("member1_power", :with => "Ruby")
fill_in("member1_bio", :with => "I love Ruby!")

The same pattern follows for the second and third superheroes. The word in quotes after fill_in needs to be set as an ID in the form to create the superheroes:

<input id="member1_name" type="text" name="team[members][][name]">

Resources

View Sinatra Nested Forms Lab: Superheroes! on Learn.co and start learning to code for free.

sinatra-nested-forms-lab-superheros-v-000's People

Contributors

victhevenot avatar ahimmelstoss avatar kthffmn avatar annjohn avatar jmburges avatar loganhasson avatar fs-lms-test-bot avatar alternative-dk avatar deniznida avatar lawrend avatar roseweixel avatar sarogers avatar fislabstest avatar ipc103 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.