CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:

Slides:



Advertisements
Similar presentations
CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:
Advertisements

CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:
Detecting Bugs Using Assertions Ben Scribner. Defining the Problem  Bugs exist  Unexpected errors happen Hardware failures Loss of data Data may exist.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
Institute for Clinical and Translational Science (ICTS) Fred McClurg Neil Nuehring New Features and Improvements in REDCap
Proprietary and Confidential. Do not distribute. 1 ERA Manager – 5010 Changes Training.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
CS 142 Lecture Notes: FormsSlide 1 Simple Form Value1: Value2:
XML and Ruby on Rails Jennifer Andrews LIS 531F April 25,2007.
CS 142 Lecture Notes: FormsSlide 1 Simple Form Value1: Value2:
CS 142 Lecture Notes: FormsSlide 1 AJAX Basics xhr = new XMLHttpRequest(); xhr.onreadystatechange = xhrHandler(); xhr.open("POST", url); xhr.send(postData);...
Computer Science & Engineering 2111 Data Validation and Macros 1 CSE 2111 Lecture-Data Validation and Macros.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Securing Ruby on Rails CIS 6939 Web Engineering with Ruby on Rails University of North Florida Stephen Jones 8 July 2007.
Homework for October 2011 Nikolay Kostov Telerik Corporation
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
Gainful Employment Webinar #10 Understanding the NSLDS Corrections Functionality October 24, 2012.
AQS Web Quick Reference Guide Changing Raw Data Values Using Maintenance 1. From Main Menu, click Maintenance, Sample Values, Raw Data 2. Enter monitor.
1.NET Web Forms Security Issues © 2002 by Jerry Post.
Form Validator “Hasta La Vista SQL Injection”. Their Job, Our Job, It’s Job Chris Anley mentions Four Best- Practices to Avoid SQL Injection Chris Anley.
1 Dr Alexiei Dingli Web Science Stream Advanced ROR.
Tom Castiglia Hershey Technologies
Ruby on Rails Your first app. Rails files app/ Contains the controllers, models, views and assets for your application. You’ll focus on this folder for.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
V 1.0Slide 1 Staff – Basic Info. V 1.0Slide 2 Staff – Basic Info Input the search criteria. Click search to start searching.
Week 9 - Form Basics Key Concepts 1. 1.Describe common uses of forms on web pages 2.Create forms on web pages using the form, input, textarea, and select.
Photo Gallery INFO 2310: Topics in Web Design and Programming.
CS 142 Lecture Notes: Rails ActiveRecordSlide 1 Model for Student Table SELECT * FROM students; | id | name.
CS 142 Lecture Notes: Rails ActiveRecordSlide 1 Model for Student Table SELECT * FROM students; | id | name.
Ruby on Rails: Databases. Rails Database Familiar Table Concept Naming convention – lower case, plural (i.e. tweets) How to Access (find), Update, Delete.
Creating PHPs to Insert, Update, and Delete Data CS 320.
InfoBox A Personal Information Manager Built with Ruby on Rails Dustin Martin.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
Training Slides – Manage Co-Curricular Activities Integrated National Education Information System (iNEIS TM )
® IBM Software Group © 2006 IBM Corporation Using JSF Mini-Calendar Controls This section describes how to use a JSF Mini-Calendar Control with EGL It.
Create, Update and Delete Carol Wolf Computer Science.
CSCI 6962: Server-side Design and Programming JSF DataTables and Shopping Carts.
CS 142 Lecture Notes: Rails ActiveRecordSlide 1 Model for Student Table SELECT * FROM students; | id | name.
Workflow Demo: Upload, Review and Approve. Cpay : Users & Functionalities Customer AdministratorCustomer AuthorizerUploaderReviewerApproverInterceptor.
11. EXCEPTION HANDLING Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
HTML5 Forms Forms are used to capture user input …
Rails and routing INFO 2310: Topics in Web Design and Programming.
CS 160 and CMPE/SE 131 Software Engineering February 9 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Introduction to information systems RUBY ON RAILS dr inż. Tomasz Pieciukiewicz.
The Controller Carol Wolf Computer Science. Rails generate commands  Using the generate command, you can create a number of useful objects.  Rails:
Struts2 Validation using XML Approach. May 12, 2011 Need For Validation Validation can be defined as the assessment of an action so as to ensure that.
CS 160 and CMPE/SE 131 Software Engineering February 11 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
Ariba Punch-Out Catalog Process Flow
START Application Spencer Johnson Jonathan Barella Cohner Marker.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
Prototype Security New Feature: Send Mass & Activity Code.
Test slide upload.
Ruby on Rails Model of MVC
MIS Professor Sandvig MIS 324 Professor Sandvig
FASTER Processing in Skyward
Model for Student Table
© 2016 Blackboard Inc. All rights reserved..
AJAX Basics xhr = new XMLHttpRequest();
AJAX Basics xhr = new XMLHttpRequest();
AJAX Basics xhr = new XMLHttpRequest();
New Salary Transfer.
Model for Student Table
VENDOR STOCK MASS UPLOAD MANUAL Enter the login id and password
Process Exchange Transactions Activity
Presentation transcript:

CS 142 Lecture Notes: FormsSlide 1 Simple Form Product: Price:

Slide 2 Controller Code for Form class StudentsController < ApplicationController def index... end def edit if params[:id] = Student.find(params[:id]) = Student.new() end def update... end Display form Handle post

Slide 3 Rails Form Helpers <input id="student_name" name="student[name]“ size="30" type="text" value="Chen" /> <input id="student_birth" name="student[birth]“ size="30" type="text" value=" " /> <input name="commit" type="submit“ value="Modify Student" /> Describes type, provides initial values Object representing form

CS 142 Lecture Notes: FormsSlide 4 Customize Format...

CS 142 Lecture Notes: FormsSlide 5 Post Action Method def = Student.find(params[:id]) = = = = params[:student][:grad] then redirect_to(:action => :index) else render(:action => :edit) end Hash with all of form data Redirects on success Redisplay form on error

Security checks in Rails 4 cause update to fail CS 142 Lecture Notes: FormsSlide 6 More Compact Approach def = Student.find(params[:id]) then redirect_to(:action => :index) else render(:action => :edit) end

CS 142 Lecture Notes: FormsSlide 7 Rails 4 Pattern def = Student.find(params[:id]) params[:student])) then redirect_to(:action => :index) else render(:action => :edit) end private def student_params(params) return params.permit(:name, :birth, :gpa, :grad) end Creates new object where specified elements allowed for mass update

CS 142 Lecture Notes: FormsSlide 8 Creating New Record def = Student.new(student_params( params[:student]) then redirect_to(:action => :index) else render(:action => :edit) end

CS 142 Lecture Notes: FormsSlide 9 Validation (in Model) class Student < ActiveRecord::Base validates :birth, format: { with: /\d\d\d\d-\d\d-\d\d/, message: "must have format YYYY-MM-DD" } def validate_gpa if (gpa 4.0) then errors.add(:gpa, "must be between 0.0 and 4.0") end validate :validate_gpa end Custom validation method Built-in validator Saves error info

CS 142 Lecture Notes: FormsSlide 10 Error Messages :update, do |form| %>......

CS 142 Lecture Notes: FormsSlide 11 File Uploads with Rails In form post method: params[:student][:photo].read() params[:student][:photo].original_filename

CS 142 Lecture Notes: CookiesSlide 12