Giter Site home page Giter Site logo

rails-form_for-lab-immersive-alum's Introduction

form_for Lab

Objectives

  1. Use form_for to build a new form
  2. Use form_for to build an edit form
  3. Mass assign form data to ActiveRecord instances on new and edit
  4. Build RESTFul actions for new, create, edit, and update, with the correct routes and route helper urls.

Instructions

For this lab you will be extending the functionality of the Flatiron school's student management application by building in the functionality to create and edit school classes. You will build all of the functionality from scratch, including building out the models, views, and controllers for the SchoolClass and Student resources.

Below is what will be needed for each component of the MVC structure:

  • Models - Create a SchoolClass model, along with its associated database table. The SchoolClass table should have the columns: title:string and room_number:integer. The Student model and database table have already been created for you.

  • Controllers - Create controller files for school_classes and students. Build out the new, create, show, edit, and update actions in each of the controllers.

  • Views - Create a show page for each resource, along with new and edit forms.

You will also need to create routes for each path mentioned above.

The tests for this application are located in the spec/controllers/, spec/features/, and spec/models/ directories.

Requirements

Utilize the form_for methods for all four of the forms and integrate each form_for call with the respective controller actions. Also make sure to utilize the <%= f.submit %> submit button syntax to have the button text automatically generated.

Since you're using form_for, make sure you are using strong parameters for the controller create and update actions, if you don't remember how to do it, here is how we implemented strong params in the README: @post.update(params.require(:post).permit(:title, :description)). (hint: you can pass the strong parameter call to the create method just like we did on update)

If you run into issues drawing the routes, inspect element on the forms to see what path form_for is automatically trying to pass the form data to.

Resources

View form_for Lab on Learn.co and start learning to code for free.

View form_for lab on Learn.co and start learning to code for free.

rails-form_for-lab-immersive-alum's People

Contributors

maxwellbenton avatar jordanhudgens avatar annjohn avatar drakeltheryuujin avatar danielseehausen avatar jmburges avatar sandyvern avatar dependabot[bot] avatar realandrewcohn avatar dandanberry avatar rrcobb avatar perpepajn25 avatar

Watchers

 avatar Mat Balez avatar Victoria Thevenot avatar  avatar Joe Cardarelli avatar Taranjyot Singh avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Antoin avatar Nicole Kroese  avatar  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.