Giter VIP home page Giter VIP logo

sinatra-basic-forms's Introduction

Basic Forms!

Deliverables

Fork this repository. Deliver your work in the master branch.

Objectives

  1. Build out basic edit/update functionality for the songs resource
  2. Create a form that produces a well-structured params hash for updating songs using mass-assignment

Instructions

  1. Bundle gems

bundle

  1. Create the database schema

rake db:migrate rake db:migrate SINATRA_ENV=test

  1. Seed the database with data

rake db:seed

  1. Run shotgun and open localhost:9393 in your browser. Click around and see what has already been built out.

Your objective for this lab will be to make it possible for users to edit songs. You'll create the necessary routes and a form to make this feature work.

Since the test suite for this uses capybara to recreate the user flow (visit the song show page, click on the edit link, fill in and submit the form), you'll have to build out the functionality with that order in mind if you want your failures to go in a logical order.

The following steps provide an overview of what you'll need to build:

Create the edit route

Create an 'edit' route in app.rb and pass it a song id. This route is going to render the songs/edit template, so also create a song instance variable to pass to the view.

Create the edit view

Create an edit view template in views/songs and build a form with named controls. The purpose of this form is to edit/update existing songs. These fields should have the songs current attributes set as their value so that they can be properly updated.

Create the update route

Create an 'update' route in app.rb. The is is the route where you will post the data from the song edit form. Inside the controller block, use the params hash to update and save the changes to the song.

Add the route action to your form

Make sure that the 'action' attribute of your form points to the correct route, and that the method is correct.

Add the edit link

Add a link on each song show page that directs users to the edit view and fix the songs!

View Basic Forms! on Learn.co and start learning to code for free.

sinatra-basic-forms's People

Contributors

tsiege avatar irmiller22 avatar roseweixel avatar deniznida avatar benjagross avatar fs-lms-test-bot avatar sarogers avatar fislabstest avatar ahimmelstoss avatar aviflombaum avatar ipc103 avatar msuzoagu avatar

Watchers

James Cloos 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.