Giter Site home page Giter Site logo

validations-in-controller-actions-rails-lab-online-web-ft-100719's Introduction

Validations In Controller Actions Lab

Time to apply these new tools!

The goal of this lab is to allow users of this blog-style application to create and edit authors and posts without worrying about typos or other mistakes leading to error-prone form submissions.

For example, if someone creates a blog post with less than 100 characters of content, it's likely that they accidentally pasted the wrong text, or misunderstood which information goes into which field. We can improve the user's experience and the stability of our codebase by notifying users about these kinds of mistakes before bad data gets into the database.

Objectives

  • Define validations on a model
  • Use the validation state of a model in a response conditional in an action
  • Re-render a form with validation errors
  • Validate a create action
  • Validate an update action

Requirements

Make sure you run rake db:seed so you have some data to work with (defined in db/seeds.rb).

This is a barebones app with two models, Author and Post. Right now, you can...

To complete this lab, you will need to:

  1. Add validations to Author such that...
  2. The name cannot be blank
  3. The e-mail is unique
  4. Add validations to Post such that...
  5. The title cannot be blank
  6. The category is either "Fiction" or "Non-Fiction"
  7. The content is at least 100 characters long.
  8. Change AuthorsController#create to re-render the form if the new author is invalid.
  9. Change PostsController#update to re-render the form if the updated post is invalid.

View Validations In Controller Actions Lab on Learn.co and start learning to code for free.

validations-in-controller-actions-rails-lab-online-web-ft-100719's People

Contributors

annjohn avatar aviflombaum avatar changemewtf avatar danielseehausen avatar dependabot[bot] avatar franknowinski avatar jmburges avatar lkwlala avatar maxwellbenton avatar pletcher avatar rrcobb avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.