SlideShare a Scribd company logo
1 of 21
www.riosoftware.com.au
Ruby on Rails + Twitter
Bootstrap + AngularJS
Delightful web development
1
Topics
• Why all of these things together ?
• Ruby on Rails App Setup
• Twitter Bootstrap Setup
• AngularJS setup
• CRUD example
• Wrapping up
Why all of these things
together ?
• Ruby on Rails is a proven web apps killer framework.
• Easy to build web apps and web api’s.
• Today’s web apps are more and more Javascript/client side
oriented.
• AngularJS is a great choice, as it is a complete front-end
non-obtrusive framework which extends the HTML
capabilities.
• Including validations, data models, state management,
and so on.
Ruby on Rails App Setup
• There are many ways to create a Ruby on Rails application.
My favourites ones are :
• rails new rails-angular-demo -m
https://raw.github.com/RailsApps/rails-
composer/master/composer.rb
• rails new rails-angular-demo
• In my setup I’m using : slim and sass to build my
templates, but fell free to use anything you want. You can
check my project out at the end of the presentation !
Rails Composer
• This is my preferred
option, as it helps to
setup the initial project
with my preferred gems. But, fell free to create it
anyway you want !
• Take a look at: https://github.com/RailsApps/rails-
composer/
Now, open your project.
(I’m using RubyMine)
6
Modifications to the Gemfile
• Add the following entries in Yellow :
source ‘https://rubygems.org'
#Add this one
source ‘http://rails-assets.org'
ruby '2.2.0'
gem 'rails', '4.2.0'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
#Add These two as well
gem ‘rails-assets-bootstrap'
gem ‘rails-assets-angularjs'
...
7
Modifying application.js
• Add these entries :
...
//= require bootstrap
//= require angularjs
...
8
Modifying application.scss
• Add this entry :
*= require bootstrap
9
AngularJS
&
Twitter bootstrap setup
• Just apply it to your templates…
10
application.html.slim
doctype html
html lang="en" ng-app="demoApp"
head
meta charset="utf-8"
meta content="IE=edge" http-equiv="X-UA-Compatible"
meta content="width=device-width, initial-scale=1" name="viewport"
meta content="" name="description"
meta content="" name="author"
link href="../../favicon.ico" rel="icon"
title Rails AngularJS Demo
== stylesheet_link_tag "application", :media => 'all'
== javascript_include_tag 'application'
== csrf_meta_tags
body
== render 'layouts/navigation'
.container
== render 'layouts/messages'
== yield
footer.footer
.container
p.text-muted
a href="http://www.riosoftware.com.au" target="_blank" title='Rio Software' Copyright Rio Software.
• The initial angular setup needs the tag ng-app=“Your Application Name"
11
customers/index.html.slim
form name="form" id="form" action="/customers/new" method="GET" novalidate="novalidate"
table.table
caption Customer Lists
thead
tr
th #
th First Name
th Last Name
th
th
tbody
- @customers.each do |customer|
tr
th scope="row"
= customer.id
td
= customer.first_name
td
= customer.last_name
td
= link_to 'Edit', edit_customer_path(customer), class: 'btn btn-primary', method: :post
td
= link_to 'Delete', customer_path(customer), class: 'btn btn-danger', method: :delete
button.btn.btn-default type="submit" Add New Customer
12
customers/new.html.slim
.customers ng-controller="CustomersController"
form name="form" id="form" action="/customers" method="POST" novalidate="novalidate"
= render 'customers/shared/customer_details'
button.btn.btn-default type="submit" ng-disabled="!form.$valid" Submit
13
customers/edit.html.slim
.customers ng-controller="EditCustomersController"
form name="form" id="form" action="#{customer_path}" method="POST" novalidate="novalidate"
= render 'customers/shared/customer_details'
input name="_method" type="hidden" value="patch"
button.btn.btn-default type="submit" ng-disabled="!form.$valid" Submit
14
customers/shared/_customer
_details.html.slim
.form-group ng-class="{'has-success' : form['customer[first_name]'].$valid, 'has-error' :
!form['customer[first_name]'].$valid}"
label for="customer[first_name]" First Name
input#first_name.form-control type="text" name="customer[first_name]" ng-
model="customer.firstName" ng-init="customer.firstName='#{@customer.first_name}'" ng-
required="true"
label class="control-label" ng-show="form['customer[first_name]'].$error.required"
for="customer[first_name]" Invalid
.form-group ng-class="{'has-success' : form['customer[last_name]'].$valid, 'has-error' :
!form['customer[last_name]'].$valid}"
label for="customer[last_name]" Last Name
input#last_name.form-control type="text" name="customer[last_name]" ng-
model="customer.lastName" ng-init="customer.lastName='#{@customer.last_name}'" ng-
required="true"
label class="control-label" ng-show="form['customer[last_name]'].$error.required"
for="customer[last_name]" Invalid
15
Your controller
class CustomersController < ApplicationController
def new
@customer = Customer.new
end
def create
@customer = Customer.new(filtered_params)
@customer.save
redirect_to customers_path
end
def index
@customers = Customer.all
end
def edit
@customer = Customer.find(params[:id])
end
def update
@customer = Customer.find(params[:id])
@customer.first_name = filtered_params[:first_name]
@customer.last_name = filtered_params[:last_name]
@customer.save
redirect_to customers_path
end
def destroy
@customer = Customer.find(params[:id])
@customer.delete
redirect_to customers_path
end
private
def filtered_params
params.require(:customer).permit(:id, :first_name, :last_name)
end
end
16
Your routes.rb
Rails.application.routes.draw do
root to: 'customers#index'
resources :customers
post 'customers/:id/edit' => 'customers#edit'
end
17
Details of AngularJS setup
• Just add the angular tags on your template
input#last_name.form-control type="text" name="customer[last_name]"
ng-model="customer.lastName"
ng-init="customer.lastName='#{@customer.last_name}'" ng-required="true"
• Add a new demo.js for your application
var demoApp = angular.module('demoApp', []);
• Add a new controllers.js
demoApp.controller('CustomersController', ['$scope', function ($scope) {
$scope.customer = {firstName: '', lastName: ''};
}]);
demoApp.controller('EditCustomersController', ['$scope', function ($scope) {
//Something is gonna happen here :-)
}]);
• Change your Add a new application.js
//= require demo
//= require_tree .
•
18
Just run your app
• rails s
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-02-13 22:21:26] INFO WEBrick 1.3.1
[2015-02-13 22:21:26] INFO ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
Wait for it…
19
Voilà
20
About us
• We are an agile Sydney based IT consultancy, focused on delivering
value to our customers and partners.
• We provide software development, consultancy, and training. We
use the best tools, languages and platforms to build the best
products.
• Our website : www.riosoftware.com.au
• Phone: 02 9432 7884
• Email: contact@riosoftware.com.au
• This slides code : https://bitbucket.org/riosoftware/rails-angular-demo
21

More Related Content

What's hot

RoR 101: Session 6
RoR 101: Session 6RoR 101: Session 6
RoR 101: Session 6Rory Gianni
 
RoR 101: Session 3
RoR 101: Session 3RoR 101: Session 3
RoR 101: Session 3Rory Gianni
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuLucas Renan
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJSRajthilakMCA
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersCaldera Labs
 
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)Jonathan Linowes
 
Active Admin
Active AdminActive Admin
Active AdminGreg Bell
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009bturnbull
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemLucas Renan
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with RailsAlan Hecht
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2A.K.M. Ahsrafuzzaman
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaJason Noble
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine UK
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Tse-Ching Ho
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworksguestf7bc30
 
Session 5 : intro to jsp - Giáo trình Bách Khoa Aptech
Session 5 : intro to jsp  - Giáo trình Bách Khoa AptechSession 5 : intro to jsp  - Giáo trình Bách Khoa Aptech
Session 5 : intro to jsp - Giáo trình Bách Khoa AptechMasterCode.vn
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfAlfresco Software
 

What's hot (20)

RoR 101: Session 6
RoR 101: Session 6RoR 101: Session 6
RoR 101: Session 6
 
RoR 101: Session 3
RoR 101: Session 3RoR 101: Session 3
RoR 101: Session 3
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP Itu
 
Rails::Engine
Rails::EngineRails::Engine
Rails::Engine
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
 
Active Admin
Active AdminActive Admin
Active Admin
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - Ecosystem
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with Rails
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
Session 5 : intro to jsp - Giáo trình Bách Khoa Aptech
Session 5 : intro to jsp  - Giáo trình Bách Khoa AptechSession 5 : intro to jsp  - Giáo trình Bách Khoa Aptech
Session 5 : intro to jsp - Giáo trình Bách Khoa Aptech
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
Catalog display
Catalog displayCatalog display
Catalog display
 

Similar to Ruby on Rails + AngularJS + Twitter Bootstrap

Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsTom Z Zeng
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js FundamentalsMark
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiPivorak MeetUp
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-publicChul Ju Hong
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatternsChul Ju Hong
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemAlex Mikitenko
 
Rails for Beginners - Le Wagon
Rails for Beginners - Le WagonRails for Beginners - Le Wagon
Rails for Beginners - Le WagonAlex Benoit
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docsAbhi166803
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsVinícius de Moraes
 

Similar to Ruby on Rails + AngularJS + Twitter Bootstrap (20)

Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
 
AngularJS
AngularJSAngularJS
AngularJS
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-public
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatterns
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Rails for Beginners - Le Wagon
Rails for Beginners - Le WagonRails for Beginners - Le Wagon
Rails for Beginners - Le Wagon
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
Angular js
Angular jsAngular js
Angular js
 
Angular
AngularAngular
Angular
 

Recently uploaded

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 

Recently uploaded (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

Ruby on Rails + AngularJS + Twitter Bootstrap

  • 1. www.riosoftware.com.au Ruby on Rails + Twitter Bootstrap + AngularJS Delightful web development 1
  • 2. Topics • Why all of these things together ? • Ruby on Rails App Setup • Twitter Bootstrap Setup • AngularJS setup • CRUD example • Wrapping up
  • 3. Why all of these things together ? • Ruby on Rails is a proven web apps killer framework. • Easy to build web apps and web api’s. • Today’s web apps are more and more Javascript/client side oriented. • AngularJS is a great choice, as it is a complete front-end non-obtrusive framework which extends the HTML capabilities. • Including validations, data models, state management, and so on.
  • 4. Ruby on Rails App Setup • There are many ways to create a Ruby on Rails application. My favourites ones are : • rails new rails-angular-demo -m https://raw.github.com/RailsApps/rails- composer/master/composer.rb • rails new rails-angular-demo • In my setup I’m using : slim and sass to build my templates, but fell free to use anything you want. You can check my project out at the end of the presentation !
  • 5. Rails Composer • This is my preferred option, as it helps to setup the initial project with my preferred gems. But, fell free to create it anyway you want ! • Take a look at: https://github.com/RailsApps/rails- composer/
  • 6. Now, open your project. (I’m using RubyMine) 6
  • 7. Modifications to the Gemfile • Add the following entries in Yellow : source ‘https://rubygems.org' #Add this one source ‘http://rails-assets.org' ruby '2.2.0' gem 'rails', '4.2.0' gem 'sqlite3' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' #Add These two as well gem ‘rails-assets-bootstrap' gem ‘rails-assets-angularjs' ... 7
  • 8. Modifying application.js • Add these entries : ... //= require bootstrap //= require angularjs ... 8
  • 9. Modifying application.scss • Add this entry : *= require bootstrap 9
  • 10. AngularJS & Twitter bootstrap setup • Just apply it to your templates… 10
  • 11. application.html.slim doctype html html lang="en" ng-app="demoApp" head meta charset="utf-8" meta content="IE=edge" http-equiv="X-UA-Compatible" meta content="width=device-width, initial-scale=1" name="viewport" meta content="" name="description" meta content="" name="author" link href="../../favicon.ico" rel="icon" title Rails AngularJS Demo == stylesheet_link_tag "application", :media => 'all' == javascript_include_tag 'application' == csrf_meta_tags body == render 'layouts/navigation' .container == render 'layouts/messages' == yield footer.footer .container p.text-muted a href="http://www.riosoftware.com.au" target="_blank" title='Rio Software' Copyright Rio Software. • The initial angular setup needs the tag ng-app=“Your Application Name" 11
  • 12. customers/index.html.slim form name="form" id="form" action="/customers/new" method="GET" novalidate="novalidate" table.table caption Customer Lists thead tr th # th First Name th Last Name th th tbody - @customers.each do |customer| tr th scope="row" = customer.id td = customer.first_name td = customer.last_name td = link_to 'Edit', edit_customer_path(customer), class: 'btn btn-primary', method: :post td = link_to 'Delete', customer_path(customer), class: 'btn btn-danger', method: :delete button.btn.btn-default type="submit" Add New Customer 12
  • 13. customers/new.html.slim .customers ng-controller="CustomersController" form name="form" id="form" action="/customers" method="POST" novalidate="novalidate" = render 'customers/shared/customer_details' button.btn.btn-default type="submit" ng-disabled="!form.$valid" Submit 13
  • 14. customers/edit.html.slim .customers ng-controller="EditCustomersController" form name="form" id="form" action="#{customer_path}" method="POST" novalidate="novalidate" = render 'customers/shared/customer_details' input name="_method" type="hidden" value="patch" button.btn.btn-default type="submit" ng-disabled="!form.$valid" Submit 14
  • 15. customers/shared/_customer _details.html.slim .form-group ng-class="{'has-success' : form['customer[first_name]'].$valid, 'has-error' : !form['customer[first_name]'].$valid}" label for="customer[first_name]" First Name input#first_name.form-control type="text" name="customer[first_name]" ng- model="customer.firstName" ng-init="customer.firstName='#{@customer.first_name}'" ng- required="true" label class="control-label" ng-show="form['customer[first_name]'].$error.required" for="customer[first_name]" Invalid .form-group ng-class="{'has-success' : form['customer[last_name]'].$valid, 'has-error' : !form['customer[last_name]'].$valid}" label for="customer[last_name]" Last Name input#last_name.form-control type="text" name="customer[last_name]" ng- model="customer.lastName" ng-init="customer.lastName='#{@customer.last_name}'" ng- required="true" label class="control-label" ng-show="form['customer[last_name]'].$error.required" for="customer[last_name]" Invalid 15
  • 16. Your controller class CustomersController < ApplicationController def new @customer = Customer.new end def create @customer = Customer.new(filtered_params) @customer.save redirect_to customers_path end def index @customers = Customer.all end def edit @customer = Customer.find(params[:id]) end def update @customer = Customer.find(params[:id]) @customer.first_name = filtered_params[:first_name] @customer.last_name = filtered_params[:last_name] @customer.save redirect_to customers_path end def destroy @customer = Customer.find(params[:id]) @customer.delete redirect_to customers_path end private def filtered_params params.require(:customer).permit(:id, :first_name, :last_name) end end 16
  • 17. Your routes.rb Rails.application.routes.draw do root to: 'customers#index' resources :customers post 'customers/:id/edit' => 'customers#edit' end 17
  • 18. Details of AngularJS setup • Just add the angular tags on your template input#last_name.form-control type="text" name="customer[last_name]" ng-model="customer.lastName" ng-init="customer.lastName='#{@customer.last_name}'" ng-required="true" • Add a new demo.js for your application var demoApp = angular.module('demoApp', []); • Add a new controllers.js demoApp.controller('CustomersController', ['$scope', function ($scope) { $scope.customer = {firstName: '', lastName: ''}; }]); demoApp.controller('EditCustomersController', ['$scope', function ($scope) { //Something is gonna happen here :-) }]); • Change your Add a new application.js //= require demo //= require_tree . • 18
  • 19. Just run your app • rails s => Booting WEBrick => Rails 4.2.0 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-02-13 22:21:26] INFO WEBrick 1.3.1 [2015-02-13 22:21:26] INFO ruby 2.2.0 (2014-12-25) [x86_64-darwin14] Wait for it… 19
  • 21. About us • We are an agile Sydney based IT consultancy, focused on delivering value to our customers and partners. • We provide software development, consultancy, and training. We use the best tools, languages and platforms to build the best products. • Our website : www.riosoftware.com.au • Phone: 02 9432 7884 • Email: contact@riosoftware.com.au • This slides code : https://bitbucket.org/riosoftware/rails-angular-demo 21