Giter Site home page Giter Site logo

sinatra-nested-forms's Introduction

Sinatra Nested Forms Lab: Pirates!

Overview

In this lab, you'll practice using nested forms in Sinatra.

Instructions

Note: YOU DO NOT NEED A DATABASE, since we just need to keep track of the form's input long enough to display it, and not persist it. We don't expect the pirate to be there the next time we come to their URL, but it'd be cool if they were.

  1. Create two classes, a Pirate class and a Ship class. Pirates should have a name, weight, and height. You will also need a class method that returns all the pirates. The ship class should have name, type, and booty attributes, as well as a class method .all that returns all the ships and a class method .clear that deletes all ships.

  2. Make a nested form (this should probably have html <label>s so it makes sense to a user). This form will be creating three objects (one instance of the Pirate class, and two instances of the Ship class). Remember, you'll need to build a corresponding controller action to load this page. Your form should POST to the route '/pirates'.

  3. After a user clicks submit they should be taken to a page that displays all the information we just posted from the form. You should have a page that shows the pirate you created along with their ships and all the details about the pirate and their ships.

Deliverables

Pass the tests! You'll notice in specs that we use Capybara to fill in certain fields. It looks something like this:

fill_in("ship_name_1", :with => "Flying Dutchman")
fill_in("ship_type_1", :with => "ghost ship")
fill_in("ship_booty_1", :with => "gold coins")

The word in quotes after fill_in needs to be set as an ID in the form. This is because your ship name one and two will have the same name property. Capybara needs some sort of unique indentifier, so we use id. So something like this:

<input id="ship_name_1" type="text" name="pirate[ships][][name]" >

Resources

sinatra-nested-forms's People

Contributors

ahimmelstoss avatar annjohn avatar benjagross avatar deniznida avatar dependabot[bot] avatar drakeltheryuujin avatar fislabstest avatar fs-lms-test-bot avatar ihollander avatar ipc103 avatar irmiller22 avatar kthffmn avatar lizbur10 avatar loganhasson avatar maxwellbenton avatar pletcher avatar roseweixel avatar sarogers avatar sgharms avatar victhevenot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sinatra-nested-forms's Issues

Instructions are confusing

Needs an overview in the desciprition to describe what you are building. Gotta give them a fighting chance of understanding the specs.

  • Make a nested form, should also explain what models this form will be submitting
  • explain their form should follow the namea provided in the spec
  • They don't know REST yet, so just tell them what route the form should submit to
  • Drop the "this is an exercise" bullet

Drop the Bonus

A little confused.

I was slightly confused by the difference between the Learn page instructions and the instructions that are within the root.erb. Is this done on purpose? I had a lot of trouble understanding exactly what the lab was wanting me to do.

no biggie, just a line left out of building hash with Ruby

It looks like my_hash["student"]["grade"] = "9" should be under my_hash["student"]["name"] = "Joe".

Also, my_hash => {"student"=> {"name" = "Joe", "course"=>{"name"=>"US History", "topic"=>"History"}}} should be my_hash => {"student"=> {"name" = "Joe", "grade" = "9", course"=>{"name"=>"US History", "topic"=>"History"}}}.

Cheers

Non-restful Solution

Would prefer if the solution reinforced restful conventions. For example, do not just render the erb show after submitting a form, but redirect to show. Also, the show view should not display all of the pirates, etc.2

cannot submitted passed test

Hi team,

I cannot submit the passed test. Have checked:
reloading the course
reopening the browser
making sure it is forked to my own version
submit twice
On github it shows committed and new pull request submitted already.

Could you help?

Misleading instructions

It seems like this lab can only be properly solved by iterating over the instance variable of our ship objects, but the instruction in the h2 tags of the show.erb file wants each ship under each of the precoded headers. This makes the lab impossible to solve if following those directions and there are no directions that say iteration must be used.

I can't tell why the spec requires iteration to be used by looking at it, so that part may not be true, but I the code I created without iteration gave the proper results but wouldn't pass the tests.

I've pushed my working solution that wouldn't pass the tests under a second branch called "wrong-solution" if anyone wants to view it in my repo.

Models in App.rb in Solution

Our solution contains models defined in app.rb. That is an anti-pattern and we should have a proper environment with a models directory or make this explicit.

Doesn't do proper nested hash in the final test

The last test does this:

  fill_in("pirate[name]", :with => "Captain Jack Sparrow")
    fill_in("pirate[weight]", :with => "190 lbs")
    fill_in("pirate[height]", :with => "5 feet 11 inches")
    fill_in("ship_name_1", :with => "Flying Dutchman")
    fill_in("ship_type_1", :with => "ghost ship")
    fill_in("ship_booty_1", :with => "gold coins")
    fill_in("ship_name_2", :with => "Black Pearl")
    fill_in("ship_type_2", :with => "merchant vessel")
    fill_in("ship_booty_2", :with => "treasure map")

We need to include this fact: https://github.com/learn-co-curriculum/sinatra-nested-forms-lab-superheros#deliverables

Root.erb text differs

Hey there,

There is text in the root.erb file, but in order to get it to pass, students are required to add text that is not anywhere except the solution file. This isn't something you can figure out without looking at the solution. I would just copy the text from the solution into the root.erb file and omit the test for it.

Lab file asks for separate display of ships, but test fails if you do that.

I have 3 example files for "show.erb".

The one currently named 'show.erb' (in pirates folder) passes the tests.

The other examples 'show1.erb' and 'show2.erb' show the 2 separate ships as the lab file asks for in labels "Display your first ships here" and "Display your 2nd ship here".

However, if you do that, the rspec test fails because it can't find "Flying Dutchman".

Please let me know if there is a way to display the 2 ships data in specific areas of the show.erb file and still pass the test. I looked at github for other student's code and did not see anyone meeting this 'requirement'. So I passed the tests and will keep moving, but want to raise the question. THANKS -Brad Smith

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.