Develop a ror application that shows the current time

Assignment Help Web Project
Reference no: EM131143706

Advanced Web Development - AJAX Lab

Aim: The aim of this lab is to understand how to implement AJAX in Rails applications

Instructions:

1. Use the VM supplied in class for this. Please refrain from using your own installs for labs.

2. Please answer all questions - you can be very brief. 

3. You may have to refer to the book/slides to understand some things.

1. Develop a RoR application that shows the current time (at the server side) to the user. The index page should have the message "The current time is: <time>". It should also have a button that says "Update". The user should be able to click the button to update the time. However, only the time portion should get updated - not the entire page.

Advanced Web Development - "Unit and Functional Testing Lab"

1. Clone the project from https://github.com/siddharthkaza/depot_p_for_lab.gitunder the lab and import into the IDE.

a. Run the application to make sure it's running in the browser.

Hint: It's always a good idea to run 'bundle update and then 'rake db:migrate' and 'rake db:seed' first - when using an application from another location. This updates any gems needed and brings the DB to its newest version.

1. Validations

Validations are methods that are placed in the model to validate data before records are entered in the database.

In the depot application, we will put in validations in the product model to prevent bad data from being entered in the database (for instance, 'a product should always have a title').

a. Run the depot application, enter a new product in the database (go to /products in the URL to get to the products listing).

b. What validations do you think the product model needs? List them here.

c. Enter the following statements in the product model (product.rb) one-by-one

validates :title, :description, :image_url, presence: true

validates :price, numericality: {greater_than_or_equal_to: 0.01}

validates :title, uniqueness: true

validates :image_url, allow_blank: true, format: {

with:    %r{\.(gif|jpg|png)\Z}i,

message: 'must be a URL for GIF, JPG or PNG image.'

}

validates :title, length: {minimum: 10}                                   

d. Create another product that fails the validations (for e.g., leave the title empty). You notice that errors show up at the top of the page after you have. How does that work? What data structures are being used in the view to show the errors?

e. Are there any more validations that you want see in the products model? Think about how you would add them. Bring them up when we discuss the lab in the class.

2. Testing

b. Study the model tests for the 'products' model in the application (they are located under the 'tests' folder). Run those model tests and see the results. The command to run all the model tests (also known as 'unit' tests) in your application is 'rake test:units'

Do you think the application needs more unit/model tests for products? Explain here.

c. Study the controller tests in the application. Run the functional tests (rake test:functionals) and see the results.

i. You will notice that some functional tests fail. Why do they fail? Study the assert_difference method for one of them. When one of the test fails you get a message:

Product.count didn't change by -1

<2> expected but was

<4>.

What do the numbers <2> and <4> mean?

ii. Fix the code so that all failing tests pass.

3. Download the address book application https://github.com/siddharthkaza/addressbook_rails42

Write two unit tests and two functional  tests for the application. See the examples in depot_p.  You might have to write the validations in the model to write unit tests.

4. How much time did you spend on this lab?

Attachment:- Assignment.rar

Reference no: EM131143706

Questions Cloud

Estimate how many miles this star travels in one year : It takes 3x107 years for a particular star to make one orbit around its galaxy. Assume that this star's orbit in its galaxy is circular with a diameter of 104 light years. A light year is the distance that light travels in one year. There are about 5..
Pay the mortgage off by repaying the outstanding balance : 4-21. When you purchased your house, you took out a 30-year annual-payment mortgage with an interest rate of 6% per year. The annual payment on the mortgage is $12,000. You have just made a payment and have now decided to pay the mortgage off by repa..
Evaluate the technology trends available to help : Your detailed promotional strategy to support theintroduction(Advertising, sales promotion, sales force, direct marketing, P/Retc) Include your promotional budget, Evaluate the technology trends available to help youmarket the product.
What is a reflective cross-site scripting attack : What is a reflective cross-site scripting attack? Which Web application attack is more likely to extract privacy data elements out of a database?
Develop a ror application that shows the current time : Develop a RoR application that shows the current time (at the server side) to the user. The index page should have the message "The current time is: ".
The following was published with the financial statements : Write a brief memo to your instructor discussing American Exploration Company's note regarding property, plant, and equipment. Your memo should address what is meant by the "successful efforts method" and "units-of-activity method."
Three largest consumer segments within particular market : After reading the chapters and lecture notes regarding marketing segmentation and target markets, select one of the following product categories (cars, trucks, SUV’s, shoe stores, men’s or women’s clothing stores, computers, beer, headphones, or fitn..
What is the main difference between a virus and a trojan : What is the main difference between a virus and a Trojan? A virus or malware can impact which of the three tenets of information systems security (confidentiality, integrity, or availability)? In what way?
Determine which proposal will be the final outcome : Finally, the last person has the right to pass it or reject it. If the last person's payoff is the smallest among the three, then the proposal will be rejected and no one will get anything. The decision making process can be done by only one time. Pl..

Reviews

Write a Review

Web Project Questions & Answers

  Create a small web site on javascripts and servlet

You are required to create a small web site on JavaScripts and Servlet. You have to choose the project idea and work in it as individual. The website must be NO less than 5 pages. At least two pages are dynamic. Use Komodo programme and editors

  What are potential risks associated with remote access

Why are users considered the weakest link in implementing policies. What are potential risks associated with remote access

  How digital media has transformed and organization advertise

Discuss how Digital Media has transformed how organizations advertise and market their products and services. Include a historical (before and after digital media). Support your discussion with reliable sources.

  How can css assist in maintaining webpages

How can Cascading Style Sheets (CSS) be used to create a unified website style? How can CSS assist in maintaining webpages

  Comparing shelf software packages

Required assistance with comparing and contrasting two main off the shelf software packages that could be implemented in an organization.

  Distinguish between good and poor user interfaces

understand the design rules that underlie good multimedia and webpage design, from both a visual and content design perspective understand what constitutes poor multimedia and webpage design.

  Develop a project plan

Be sure to propose options and make decisions for these major security decisions and justify those decisions.

  Design a lan for a very successful cpa firm

Assume you have been assigned to create a LAN for a very successful CPA firm with five departments in one building and a total of 560 workers.

  Create a customer experience map that illustrates the path

Create a customer experience map that illustrates the path a customer will take to complete the same task you identified for the user journey component of Milestone Five.

  Select artwork to be optimized for the web

Select artwork to be optimized for the web. Develop a formal mood board to guide your portfolio site design. Determine your personal style, and works to be included in your portfolio site

  Visual basics and what they have in common

Summarize a basic overview of LINQ to XML, C#, Visual basics and what they have in common.  Also How does Java work and how does a Java program that uses SAX parser to print the contents of an XML document work and look like?

  The principles of web design

Match the following web design key terms with their correct definitions. Use the Principles of Web Design Week One readings as a resource.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd