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,

Slides:



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

17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
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.
Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
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.
Languages for Dynamic Web Documents
Drupal Create a website/web app quickly with this Content Management System Jiaying Xu Spring 2011 COMS E6125 Web-enHanced Information.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
27-Jun-15 Rails. What is Rails? Rails is a framework for building web applications This involves: Getting information from the user (client), using HTML.
Website Development with PHP and MySQL Introduction.
Presented by Mina Haratiannezhadi 1.  publishing, editing and modifying content  maintenance  central interface  manage workflows 2.
Ruby on Rails CSE 190M, Spring 2009 Week 5. Installing Rails First, install Ruby with RubyGems Then, install the Rails gem gem install rails -version=2.3.2.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
Ruby on Rails (Slides modified by ements-2ed.shtml)
Overview of Framework by Ahamed Rifaudeen A. page - i Steps before entering into the Framework?  Basic knowledge of object-oriented programming (OOP)
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
The Easiest Way to Write Web Applications Jordi Sastre IT Architect, PSC May 2012.
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 CSCI 6314 David Gaspar Jennifer Garcia Avila.
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
Fall CIS 764 Database Systems Engineering L3: Two Assignments Relating to J2EE.
Library à la Carte: Customize|Collaborate|Connect Overview & Demo Kim Griggs & Jane Nichols Oregon State University.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Lecture 8 – Platform as a Service. Introduction We have discussed the SPI model of Cloud Computing – IaaS – PaaS – SaaS.
Sikuli Ivailo Dinkov QA Engineer PhoneX Team Telerik QA Academy.
Server-side Scripting Powering the webs favourite services.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
Unit 1 – Web Concepts Instructor: Brent Presley. ASSIGNMENT Read Chapter 1 Complete lab 1 – Installing Portable Apps.
MVC & ActiveRecord by Christian Mohr & Mohamed Souiai.
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
1 Dr Alexiei Dingli Web Science Stream Introducing Rails.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
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.
Lecture 11 Rails Topics SaaSSaaS Readings: SaaS book Ch February CSCE 740 Software Engineering.
Ruby on Rails CSE 190M, Spring 2009 Week 6. Overview How to use a database Demo creating a blog application on Rails Explain how the application works.
Peter Laird. | 1 Building Dynamic Google Gadgets in Java Peter Laird Managing Architect WebLogic Portal BEA Systems.
The Active Record Paradigm Databases in Database-Centric Web Site Development.
Ruby on Rails (Slides modified by ements-2ed.shtml)
1 Welcome to CSC 301 Web Programming Charles Frank.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
WEP Presentation for non-IT Steps and roles in software development 2. Skills developed in 1 st year 3. What can do a student in 1 st internship.
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
RUBY ON RAILS (RoR) Ishwor Khadka. Why Ruby on Rails?
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Web Technologies Lecture 8 Server side web. Client Side vs. Server Side Web Client-side code executes on the end-user's computer, usually within a web.
Lecture 13b Rails – Controllers and Views Topics SaaSSaaS Readings: SaaS book Ch March 3, 2014 CSCE 740 Software Engineering.
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.
Class03 Introduction to Web Development (Hierarchy and the IDE) MIS 3501, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University.
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
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.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
Model-View-Controller an introduction to MVC design pattern with Castle.MonoRail Presentation: v1.0 Prepared by: Chorn Sokun
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.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
1 Rails for the Ruby-Impaired John Paul Ashenfelter CTO/Transitionpoint.
J2EE Platform Overview (Application Architecture)
Class03 Introduction to Web Development (Hierarchy and the IDE)
Play Framework: Introduction
CMPE 280 Web UI Design and Development October 24 Class Meeting
Bruce Scharlau, University of Aberdeen, 2017
Ruby on Rails by Manik Juneja
Ruby on Rails by Manik Juneja
Presentation transcript:

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, handle user authentication, has built- in database functionality, etc. Ruby is a “ruby gem” it is written in Ruby gem is a package in Ruby (note > gem list --local will list all the gems installed on your machine) (see current install but in past installed via > gem install rails)

Advantages Convention over Configuration Less code, but can be confusing to beginners. A lot of “automagic” behavior

Advantages Active (smaller—well then java) community, resources The pains of Rails are quickly getting better Gems (again these are Ruby pacakges you can install) Bootstrap-sass, jquery-rails – automatically imports those Faker – tool to automatically generate fake data Rspec, capybara – testing integrated with rails (TDD) Guard – automatically watch files and run tests

Disadvantages Things are changing quickly can have compatibility issues (rvm and gemsets help to solve this) High initial learning curve Lots of black magic Forced to do things “the Rails Way” Rails makes assumptions about the best way to do things. It can be hard to get Rails to do what you want *the way that you want it*.

Ruby Need a subset of Ruby to start using Rails. See other lecture on Ruby

The Rails Way Convention Over Configuration Rails makes assumptions about what you want to do and how you’re going to do it, but, this may be constraining REST is the best pattern for web applications – organizing your application around resources and standard HTTP verbs is the fastest way to go.

REST “Representational State Transfer” Using resource identifiers such as URLs to represent “resources”.

Resources Example with a “user” resource Get back to this when talking about controllers. Rails expects your URLs to be like this for every single of your resources (users, posts, tweets, etc.)

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.

Models (with demo) the information (data) of the application and the rules to manipulate that data. Business logic should be concentrated here. Models are usually related to tables in a database. Model’s attributes are “columns”. But not always. Models that are not related to database tables are transient. EXAMPLE: If a model is related to a table, the table’s name will be “line_items” for model LineItem, for example. Demo: app/model/user.rb

Models Use interactive “rails console” to play with your models (and even modify your database) Can also access the methods in your controllers (next slide) Examples of methods on models: david = User.find_by_name('David') users = User.where(name: 'David', occupation: 'Code Artist').order('created_at DESC') user.update(name: 'Dave') More: User.new, User.save, User.create, User.first, User.all, User.destroy

Controllers (with demo) Glue between model and view 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. Demo: app/controllers/user_controllers.rb

Controllers conform to REST The expectation is that each controller corresponds to a resource and each controller action corresponds to a RESTful action. To tweak, go to config/routes.rb

RESTful controller actions

Views the user interface of your application all code in views should deal with presentation of data. usually HTML with embedded Ruby Rails will automatically render a view at the end of a controller action. If action was “index”, Rails will render index.html.erb Demo: app/views/user/index.html.erb

Views Additional organization to view files Layouts (application.html.erb) Partials (_header.html.erb)

Rails tools Rails comes with a ton of tools Manage your databases Generate boilerplate code Generators rails generate controller Users new rails generate model User name:string string

Structure of the Rails Project Directory subset of the most common directories. There’s also directories for tests, rails (rake) tasks, etc. You will put a lot of the code in app/* directories

App Directory Where you have most of your application code, like your Models, Views and Controllers (more about this in future lectures) app/assests = images, CSS, javascript files

Config Directory Contains various config files database.yml = information to connect to your database routes.rb = file specifying routes (mapping between URIs and methods called in your Controller classes) config/environments = can run in developer, test and production and will keep data separately

Docs Directory Tool called rdoc that will create documentation from code. Will not cover.

Lib and Log and Public Directories Lib = to change how rails work Log = text file to show requests to server, etc. public = root of webserver, used to (in older rails) have index.html file here. NOW, we have view files *.html.erb located inside the app/views folder. We will discuss Views in a later lecture

How to do Static Pages Demo: config/routes.rb Demo: app/controllers/static_page_controller Demo: app/views/static_pages/home.html.erb

Installing Rails Currently you install ruby first that includes gems program which you use to install rails (gem install rails) See tips on website if you have any problems.

Deploying Rails Your own server OR You can run it on Heroku ("cloud application platform") or with Phusion Passenger (module for Apache). IDE: well there are a few options out there (do a web search) and even some develop only with text editors and command line tools (yuck for me)  Choices include Aptana (Eclipse), Netbeans, RubyMine and more

Rails More Will learn in other lectures about Databases and more about Model, View, Controllers.

Sample Code