Ruby on Rails - a .NET Perspective

PP
by Paula Paul1 view·Updated Jun 2, 2015
Powered by AI

Need to present on this topic?

Create your own polished presentation in minutes. Just describe what you need.

Free to try, no credit card required

Transcript

Rails U

Behind the Scenes

Rails Toolchain

Rails Routing

Rails Asset Pipeline

Enough with the slides already!!!!

Resources and Routes

Assets

  • Images
  • Stylesheets
  • Javascripts
  • Headaches

Performance

Maintenenance

Deployment

The Asset Pipeline

Features:

Concatenation

Compression / minification

Precomilation (of HLL)

Fingerprinting

Introduced in Rails 3.1 (2011)

Relies on sprockets: Ruby gem for compiling & serving web assets

Hashes the content into the filename

“application-908e25f4bf64186...f54.css”

Does not rely on URL parameters....

Easy to cache, and easy to "bust" the cache

No more worrying about cache directives

Typical student hardware:

  • Laptops from Win 7 to 8.1
  • Macs from Snow Leopard to Yosemite
  • Chromebook

Development & Deployment

Asset Pipeline in Development

Files are compiled on demand; for easier debugging

Assets are not fingerprinted (no ugly filenames)

Asset Pipeline in Production

Assets are precompiled into public/assets/

Assets are fingerprinted (ugly filenames, fixes caching issues)

Perspective

Typical student:

  • There is no typical student

Things I've been told in the past 30-ish years:

Classroom Toolchain Setup

1. Ruby and Rails

Install on Win, Mac, Xnix (Raspberry Pi)

2. Syntax highlighting text editor

Install Sublime (free version)

3. Git

Install Git locally for source code control

4. Shell command prompt

On Win, Git installs Bash with fancy prompt

5. Browser

Typically Chrome

6. Internet access to rubygems.org

'package manager'

Or: 5 and 6 + free Nitrous.io VM

Rails 'Workflow'

From the command prompt:

1. rails new <app>

2. cd <app>

3. rails g scaffold

Generates MVC files as needed, based on your domain model

4. rails g controller (or other components)

Generates controllers, helpers, etc. as needed; e.g, for a Pages controller with home and about pages

5. rake db:migrate

Creates the back end database tables for scaffolded resources

In a text editor:

6. add associations to model files

7. define a root route

8. make things look cool (change views, add bootstrap/foundation, etc.)

IBM PC great for dialing in to the mainframe

Microsoft ok for the desktop, not the data center

.NET not secure enough for production use

Cloud we'll never put our data in the cloud

Rails I've heard it's not scalable

Finally, we can run Rails on IIS 8 without pain.

http://www.hanselman.com/blog/AnnouncingRunningRubyOnRailsOnIIS8OrAnythingElseReallyWithTheNewHttpPlatformHandler.aspx

What's Ruby on Rails?

Ok, Scalability.

Many well thought out opinions

http://www.ballistiq.com/2014/06/scaling-rails/

http://canrailsscale.com

Other perspectives...

and...

See for yourself!

March 10

with Jim Van Fleet

http://www.meetup.com/charlotte-rb/events/218844265/

Ruby

Many examples of high volume Rails sites

Built on Rails...

https://thecoderfactory.com/posts/top-15-sites-built-with-ruby-on-rails

Groupon

Shopify

Airbnb

Bloomberg

Object oriented, general purpose programming language

Developed by Yukihiro Matsumoto, in the mid-90s

Designed to be simple and mimic english

Considered an easy language to learn

Why am I here?

What's Rails

really, what's Rails??

A Ruby gem (think library or package)

An MVC framework for building web apps

Rails includes an ORM gem: Active Record

Features of Active Record (Rails ORM)

  • Data is represented as models.
  • Associations can be implemented using these models.
  • Inheritance can be achieved through related models.
  • Data validation can be defined and enforced on models.
  • Data is manipulated via OO database operations.

ActiveRecord is included with Rails, but can be installed as an independent gem.

What is Rails?

I killed a tree, accidentally.

But, before we get to that...

Approachable

Remember Visual Basic?

Teachable

Non-intimidating 'IDE', readable, explainable

Enjoyable

If you've never written a web app, you should!

Simple and Capable

In an 80/20 world, Rails is a contender

What's the cost of complexity?

(sorry, tree!)

The Tree

Me

I'm always looking for new sample apps to teach

Texty, TheForce, Travel, Pinterest, MusicDB...

Swapi.co - JSON sample

Twillio integration sample

'Pinteresty' sample with Bootstrap

Google maps sample

Who are Rails Programmers?

ASP.NET MVC 5, Contoso University!

Simple app. What a great example of how MVC skills in Rails translate to other frameworks.

Husband Bob

CTO, programmer, COM, C/C++ & Xamarin

Two sons (12 and 14)

Taekwondo, bassoon, Minecraft (java), Destiny

Lots of technology

14 computers, 6-7 VMs,

Minecraft server, 2 Raspberry Pi's,

Android, Apple and Microsoft tablets

Home.

Entrepreneur-able ?

Corporate Innovation-able ?

Hireable

Built it in Ruby on Rails

One last plug for my peeps...

Contoso University Sample

ASP.NET MVC 5

Entity Framework 6

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

My Perspective

"All facts come with a point of view"

The 'Rails U' class notes walk students through scaffolding, associations, Bootstrap styling, paging and search

Former IBM & MSFT employee (programmer)

A *bunch* of languages

Four processor architectures: 360, x86, PowerPC & ARM

MSFT Certs since WOSA

VB3 through C# MCSD, SQL & SP

Consulting (MSFT stack) by day

Teaching Rails for TTS by night

Code + doc is on Github - pull requests are welcome!

https://github.com/PaulaPaul/RailsU

We'll look at both versions

Disclaimers

I am neither an 'expert' in .NET, nor in Rails

Just a professional, fortunate to be making a living in both stacks at the moment...

"RailsU" is my Rails version of Contoso University

It's not identical, just similar (for teaching purposes)

I never met a programming stack I didn't like...

Ruby on Rails: a .NET Perspective

Paula Paul

@paulapaultweets

paula.paul@paulapaul.com

https://github.com/PaulaPaul