Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Presented by: Maciej Mensfeld RoR: easier, faster, better mensfeld.pl github.com/mensfeld.

Slides:



Advertisements
Similar presentations
XIr2 Recommended Performance Tuning Andy Erthal BI Practice Manager.
Advertisements

Using the Self Service BMC Helpdesk
Location Tracker Maciej Mensfeld Presented by: Maciej Mensfeld Location Tracker dev.mensfeld.pl github.com/mensfeld.
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 User authorization & safety Maciej Mensfeld Presented by: Maciej Mensfeld User authorization & safety dev.mensfeld.pl.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 7: Planning a DNS Strategy.
BUSINESS DRIVEN TECHNOLOGY
Chapter 1 Understanding the Web Design Environment
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
INTRO TO MAKING A WEBSITE Mark Zhang.  HTML  CSS  Javascript  PHP  MySQL  …That’s a lot of stuff!
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
RESPONSIVE DESIGN Sources: Kadlec, T. (2012). Implementing responsive design. Berkeley, California: New Riders Publishing. MarcotteMarcotte, E. (2010).
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
Chapter 3.1 – RoR: An introduction Maciej Mensfeld Presented by: Maciej Mensfeld RoR: An introduction dev.mensfeld.pl github.com/mensfeld.
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,
Ruby on Rails CSCI 6314 David Gaspar Jennifer Garcia Avila.
Chapter 1 Variables in the Web Design Environment.
Chapter 1 Variables in the Web Design Environment
Students: Ilya Paskhover, Itay Gal Supervisors: Oleg Rokhlenko, Nadav Golbandi.
CHAPTER 11 Tables. How Are Tables Used Data Display  Very tidy and very useful Better Text Alignment  Putting text in tables allows you to format indents.
Lab 8 – C# Programming Adding two numbers CSCI 6303 – Principles of I.T. Dr. Abraham Fall 2012.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Unit J: Creating a Database Microsoft Office Illustrated Fundamentals.
WorkPlace Pro Utilities.
Chapter 1: Introduction to Web
CO1552 – Web Application Development Lists, Special Characters, and Tables.
Introduction to InfoSec – Recitation 7 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Chapter 4.1 – Deeper into Rails Maciej Mensfeld Presented by: Maciej Mensfeld Deeper into Rails mensfeld.pl github.com/mensfeld senior.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Basic Responsive Design Techniques. Let’s take a look at this basic layout. It has a header and two columns of text, in a box that is centered on the.
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
Copyright 2012 Adobe Systems Incorporated. All rights reserved. ® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® Copyright 2012 Adobe.
USING PERL FOR CGI 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.
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.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Application Development for mobile Devices
Storing Organizational Information - Databases
Chapter 17 Creating a Database.
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
CSS BEST PRACTICES.
Crazy New CSS Tools MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
Chapter 5 Working with Tables Principles of Web Design, 4 th Edition.
Web applications – what & why? Maciej Mensfeld Presented by: Maciej Mensfeld Web applications – what & why? dev.mensfeld.pl github.com/mensfeld.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Positioning Objects with CSS and Tables
Chapter 2 - OOP Maciej Mensfeld Presented by: Maciej Mensfeld More about OOP dev.mensfeld.pl github.com/mensfeld.
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
Responsive Web Design (RWD) MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/11/2016.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Textbook to be published by Pearson Ed in early Bootstrap.
Text2PTO: Modernizing Patent Application Filing A Proposal for Submitting Text Applications to the USPTO.
A gentle introduction to Bootstrap TDAP Jeremy Shafer Department of MIS Fox School of Business Temple University Spring
Selenium and Selenium on Rails
GO! with Microsoft Office 2016
CS 321: Human-Computer Interaction Design
GO! with Microsoft Access 2016
Creating a Baseline Grid
IS1500: Introduction to Web Development
Bootstrap 4 December 17, 2018.
Unit J: Creating a Database
Web Application Development Using PHP
Presentation transcript:

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Presented by: Maciej Mensfeld RoR: easier, faster, better mensfeld.pl github.com/mensfeld senior ruby senior ruby

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Please… …ask me to slow down, if I speak to quickly; …ask me again, if I forget; …ask questions, if anything i say is not clear; …feel free to share your own observations RoR: easier, faster, better

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Make it good looking and make it fast! RoR: Bootstrap

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld RoR: Bootstrap GRID:FLUIDGRID:FIXEDLAYOUT/FLUIDLAYOUTRESPONSIVEDESIGN:TYPOGRAPHY: CODEVIEWTABLES:FORMS:BUTTONS:ICONS:BUTTONGROUPS:TABS:PILLS:NAVLIS TS:NAVBARBREADCRUMBS:PAGINATION:PAGER:INLINELABELSBADGES:PAGEHEA DERUNIT:HEROUNITTHUMBNAILS:ALERTS:PROGRESSBARS:WELLSCLOSEICON:M ODALS:DROPDOWNS:SCROLLSPYTOGGLABLETABS:TOOLTIPS:POPOVERS:COLLAPS ECAROUSEL:TYPEAHEAD Sleek, intuitive, and powerful front-end framework for faster and easier web development. github.com/twitter/bootstrap twitter.github.io/bootstrap builtwithbootstrap.com wrapbootstrap.com

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Bootstrap installation bundle install Gemfile: gem "less-rails" gem "twitter-bootstrap-rails" rails generate bootstrap:install less rails g bootstrap:layout application fluid

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Bootstrap basics: grids The default Bootstrap grid system utilizes 12 columns, making for a 940px wide container without responsive features enabled. With the responsive CSS file added, the grid adapts to be 724px and 1170px wide depending on your viewport. Below 767px viewports, the columns become fluid and stack vertically.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Bootstrap basics: grids For a simple two column layout, create a.row and add the appropriate number of.span* columns. As this is a 12-column grid, each.span* spans a number of those 12 columns, and should always add up to 12 for each row (or the number of columns in the parent). Make any row "fluid" by changing.row to.row-fluid. The column classes stay the exact same, making it easy to flip between fixed and fluid grids. The fluid grid system uses percents instead of pixels for column widths. It has the same responsive capabilities as our fixed grid system, ensuring proper proportions for key screen resolutions and devices.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Bootstrap basics: grids Move columns to the right using.offset* classes. Each class increases the left margin of a column by a whole column. For example,.offset4 moves.span4 over four columns.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Responsive bootstrap For faster mobile-friendly development, use these utility classes for showing and hiding content by device. Below is a table of the available classes and their effect on a given media query layout (labeled by device).

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Responsive bootstrap

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Controllers

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Controllers Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used. The opposite of lazy loading is eager loading.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Controllers

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Views & forms

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Views & forms Basic HTML & CSS knowledge required

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Views & forms Forms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of form control naming and their numerous attributes. Rails deals away with these complexities by providing view helpers for generating form markup. However, since they have different use-cases, developers are required to know all the differences between similar helper methods before putting them to use.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Generators

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Generators Rails generators are an essential tool if you plan to improve your workflow. rails g

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Generators

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Sessions HTTP is a stateless protocol. Sessions make it stateful. Most applications need to keep track of certain state of a particular user. This could be the contents of a shopping basket or the user id of the currently logged in user. Without the idea of sessions, the user would have to identify, and probably authenticate, on every request. Rails will create a new session automatically if a new user accesses the application. It will load an existing session if the user has already used the application.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Sessions Do not store large objects in a session. Instead you should store them in the database and save their id in the session. This will eliminate synchronization headaches and it won’t fill up your session storage space (depending on what session storage you chose, see below). This will also be a good idea, if you modify the structure of an object and old versions of it are still in some user’s cookies. With server-side session storages you can clear out the sessions, but with client-side storages, this is hard to mitigate. Critical data should not be stored in session. If the user clears his cookies or closes the browser, they will be lost. And with a client-side session storage, the user can read the data. Rails provides several storage mechanisms for the session hashes. The most important are ActiveRecord::SessionStore and ActionDispatch::Session::CookieStore.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Sessions rake db:sessions:create rake db:migrate vim config/initializers/session_store.rb: Rails.application.config.session_store :active_record_store

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing, testing, testing Testing support was woven into the Rails fabric from the beginning. It wasn’t an “oh! let’s bolt on support for running tests because they’re new and cool” epiphany. Just about every Rails application interacts heavily with a database – and, as a result, your tests will need a database to interact with as well. To write efficient tests, you’ll need to understand how to set up this database and populate it with sample data. Every Rails application you build has 3 sides: a side for production, a side for development, and a side for testing.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing - Fixtures For good tests, you’ll need to give some thought to setting up test data. In Rails, you can handle this by defining and customizing fixtures. Every Rails application you build has 3 sides: a side for production, a side for development, and a side for testing.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing - Fixtures Fixtures is a fancy word for sample data. Fixtures allow you to populate your testing database with predefined data before your tests run. Fixtures are database independent and assume a single format: YAML. You’ll find fixtures under your test/fixtures directory. When you run rails generate model to create a new model, fixture stubs will be automatically created and placed in this directory. YAML-formatted fixtures are a very human-friendly way to describe your sample data. These types of fixtures have the.yml file extension (as in users.yml).

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing - Fixtures Rails by default automatically loads all fixtures from the test/fixtures folder for your unit and functional test. Loading involves three steps: Remove any existing data from the table corresponding to the fixture Load the fixture data into the table Dump the fixture data into a variable in case you want to access it directly

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing - Units In Rails, unit tests are what you write to test your models and libs. Many Rails developers practice Test-Driven Development (TDD). This is an excellent way to build up a test suite that exercises every part of your application.

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Testing - Units

Chapter 3.2 – RoR: easier, faster, better Maciej Mensfeld Live long and prosper! Presented by: Maciej Mensfeld dev.mensfeld.pl github.com/mensfeld