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.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Introduction to Rails.
Advertisements

Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
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.
2.744 Dreamweaver Tutorial Sangmok Han Feb 24, 2010.
Ruby (on Rails) CSE 190M, Spring 2009 Week 3. Web Programming in Ruby Ruby can be used to write dynamic web pages Similar to PHP, chunks of Ruby begins.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
Ch. 5 Web Page Design – Templates and Style Sheets Mr. Ursone.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
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.
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Web Client/Server Communication A290/A590, Fall /09/2014.
 What I hate about you things people often do that hurt their Web site’s chances with search engines.
UNIT-V The MVC architecture and Struts Framework.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
RUBY ON RAILS Mark Zhang. In this talk  Overview of Ruby on Rails  Core ideas  Show a tiny bit of example code  Touch on several general web development/
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
Web Application Development Technology เทคโนโลยีสำหรับการพัฒนาโปรแกรม ประยุกต์เว็บ Suntorn Witosurapot Phone: or
Web Servers Don McGregor Research Associate MOVES Institute
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Lab Assignment 7 | Web Forms and Manipulating Strings Interactive Features Added In this assignment you will continue the design and implementation of.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
Planning a Web Site Unit Two Planning Steps 1. Determine the audience & objectives. 2. Sketch a storyboard or flowchart of the pages. 3. Create a folder.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Server-side Scripting Powering the webs favourite services.
Chapter 4.1 – Deeper into Rails Maciej Mensfeld Presented by: Maciej Mensfeld Deeper into Rails mensfeld.pl github.com/mensfeld senior.
Assignment 2 Due November 4, 1:30pm. Website You are creating a website for a fictional business which must sell some sort of product You can create any.
MVC & ActiveRecord by Christian Mohr & Mohamed Souiai.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
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.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Adobe Dreamweaver CS3 Revealed CHAPTER THREE: WORKING WITH TEXT AND IMAGES.
Chapter 6 Server-side Programming: Java Servlets
Google App Engine Using Templates Jim Eng Thanks to Chuck Severance
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Introduction to MVC Controllers NTPCUG Tom Perkins, Ph.D.
A process of taking your best guesses. Companies have web sites where you can access your information.
Macromedia Dreamweaver 8 Revealed AND GRAPHICS WORKING WITH TEXT.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
HTML IMAGES. CONTENTS IMG Tag Alt Attribute Setting Width and Height Of An Image Summary Exercise.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Ruby on Rails Controller of MVC. Routes How we map URIs like /tweets/1 to calling the show method of the Controller.
Rails and routing INFO 2310: Topics in Web Design and Programming.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
2008 Freshmen Java Project Produced by 2008 IDS Freshmen.
CSU Extension Webpage Template Session 4 February 2010.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
CGS 3066: Web Programming and Design Spring 2016 PHP.
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
Basics Components of Web Design & Development Basics, Components, Design and Development.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
1 Using MVC 6. MVC vs. ASP Web Forms Both run under ASP.NET Can coexist In Web Forms, browser requests page. xxx.aspx and xxx.aspx.cs on the server Page.
MVC Architecture, Symfony Framework for PHP Web Apps
Play Framework: Introduction
Introduction to MVC PHP Web Development Ivan Yonkov Training Manager
MVC Framework, in general.
Chapter 15 Introduction to Rails.
Developing a Model-View-Controller Component for Joomla
Web Programming and Design
Presentation transcript:

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 Code Reusability Making it clear where different types of code belong for easier maintenance

MVC Model - the information (data) of the application and the rules to manipulate that data. Business logic View – takes data and displays it Controller – the glue between the model and controller. In Rails, they’re responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.

View – The interface (here a web-app interface)

Continuing with the Zombie tutorial We have the following file structure now NOTE: erb = Embeddable Ruby This means (like jsp) these files have HTML and Ruby in them

Remember the Zombie example Databases zombies and tweets

View to show a single Tweet In app/views/tweets/show.html.erb Looks a bit like jsp … ….. Posted by NOTE: Show the 1 st Tweet in the database tweets evaluate contents evaluate & print Results Where can I get a bite to eat? Posted by Ash

ALTERNATIVE: View to show a single Tweet --- put static in separate file NOTE: every page loads application.html.erb that has static code THEN --- brings in the specific ruby code you called in show.html.erb

Now we have the following file structure

What is application.html.erb AGAIN – it is the wrapper –like where you put your html template code, css, etc. Your logo, nav bar, etc.

Web link_to –ruby on rails – link to pull in data Where can I get a bite to eat? Posted by GENERAL: Results FROM BLUE Where can I get a bite to eat? Posted by Ash

Web – link_to, confirmation option You can also ask user with confirm attribute if they really want to perform the link operation <% link_to tweet.zombie.name, tweet.zombie, confirm: “Are you sure?”%>

Lets create index.html.erb to list ALL tweets in the Zombie example This line cycles through all the entries in tweets database, creating a Tweet Model instance named tweet in a loop.

Results of index.html.erb

Add some more links, link_to and have special links to delete or modify First 2 link_to look similar. edit_tweet_path(tweet) will bring up option to edit the corresponding tweet delete will call the delete method on the corresponding tweet

What is going on ---there are predefined URL generator methods in RoR HOW TO USE GENERALLY: Example ”delete”, :controller=>”tweet’, :id=>tweet.id } %> <%= link_to "Nonsense search", searches_path(foo: "bar", baz: "quux") # => Nonsense search

View to read in parameters passed to URL How to read in parameters (URI?p1=v1&p2=v2) In your view_file.html.erb have the following. NOTE: params is reserved hash object in Rails The params hash contains the following values: : REQUEST: MEANS: params[:ids] will now be ["1", "2", "3"].

OUTPUT View to read in parameters passed to URL say.html.erb file HelloWorld_Rails Example Current TIme is The params hash contains the following values: : REQUEST:

Remember the assets directory in your project ---lets look at putting some image(s) there and using in our view

Using image in the assets folder you can access images in the public/assets/images directory like this: (here the file rails.png is stored) In your view whatever.html.erb: If instead it was in the sub-directory icons: