GithubHelp home page GithubHelp logo

active_record_and_sinatra's Introduction

Overview

In order to protect the integrity of your data, you will often need to prevent users from creating records with information that doesn't meet your constraints. A good practice is to inform the user why you did not save the data, and allow them to correct their errors.

Start with this skeleton and follow the instructions below.

Core

Use ActiveRecord and Sinatra to allow anyone to create an event, so long as it passes validation rules.

Objectives

Add validations to the Event model and show appropriate messages to the user when the validations fail.

  1. Prevent Events from being saved when: a. The events date is empty, in the past, or is not valid. b. The events title is already taken or empty. c. The event organizers name is empty. d. The event organizers email address is invalid.

You Will Know You Are Done When:

  1. Invalid Events are not created when the form is posted.
  2. The user is informed for each failing validation.
  3. The form remains populated with the users input after posting.
  4. Bonus points if errors are presented near the invalid form field.

Stretch OPTIONAL

An even better practice is to guide the users input to follow the format your program expects and/or make your program more flexible regarding the data it accepts from the user.

Computers should serve people. Not the other way around.

Objectives

  1. Modify the UI so a user is coerced into entering a valid date. Hint: Consider using a Datepicker.
  2. Modify the controller or model to be more flexible with the format of dates it accepts while still saving reasonable dates to the database. Hint: look into the rubygem Chronic.

active_record_and_sinatra's People

Contributors

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