20
Introduction to Padrino Toronto Ruby Brigade http://www.padrinorb.com/

Introduction to Padrino

Embed Size (px)

DESCRIPTION

An introductory presentation to the Ruby Padrino web development framework given at Toronto Ruby Brigade talk August 2011

Citation preview

Page 1: Introduction to Padrino

Introduction to PadrinoToronto Ruby Brigade

http://www.padrinorb.com/

Page 2: Introduction to Padrino

What is Padrino?

A Framework built on top of Sinatra

...a 'micro-framework'

● good for small web application● small footprint● easy to learn and use

Page 3: Introduction to Padrino

What is Padrino?

● A quote from the Padrino mailing list:○ The Padrino framework appreciates and believes in the

philosophy of Sinatra [in] keeping things simple, elegant, and 'closer to the metal' while still allowing you to express yourself in a ruby-esque manner. However at times it's nice to have some more additional functionalit[y] (like helpers, mailers, even caching) that Rails does [have]; and it's nice to have those features without leveraging their full opinionated stack.

■ Arthur Chiu

Page 4: Introduction to Padrino

How is it different than Sinatra?

Adds generators for building projects:● Can be 'tiny'

○ padrino g project my_project --tiny ● Can be 'Rails like'

○ padrino g project my_big_project -d activerecord -s prototype -e erb -a sqlite -t rspec -m mocha

Page 5: Introduction to Padrino

padrino g project my_project --tiny

Page 6: Introduction to Padrino

padrino g project my_big_project -d activerecord -s prototype -e erb -a sqlite -t rspec -m mocha

Page 7: Introduction to Padrino

How is it different than Sinatra?

Helpers and functionality familiar to Rails developers:● Tag helpers (tag, content_tag, input_tag, form_tag, link_to, image_tag)● Mailer functionality (similar to ActiveMailer)● Admin Interface (inspired by Django)● Reloading (automatically reloads server, previously you had to use

something like 'shotgun' to have this behaviour with Sinatra -- never a problem with Rails)

● Localization support● [complete list: http://www.padrinorb.com/]

Page 8: Introduction to Padrino

How is it different than Rails?

Has a flexible project generator:● padrino g project test_app -d datamapper -b● padrino g project test_app -d mongoid -t rspec -e haml -m rr -s

jquery -b● padrino g project test_app --test none --renderer none● Plugin Generator

○ ...● [more details: http://www.padrinorb.com/guides/generators]

Page 9: Introduction to Padrino

How is it different than Rails?

Mounting sub-applications:● Extend application functionality by building 'apps'

○ Build apps within an app■ Padrino.mount("blog").to("/blog")■ Padrino.mount("website").to("/website")■ Padrino.mount("app").to("/")

Advanced mounting:● Padrino.mount("Blog").to("/").host("blog.example.org")● Padrino.mount("Admin").host("admin.example.org")● Padrino.mount("WebSite").host(/.*\.?example.org/)● Padrino.mount("Foo").to("/foo").host("bar.example.org"

[more details: http://www.padrinorb.com/guides/mounting-applications]

Page 10: Introduction to Padrino

padrino g app my_sub_app

Page 11: Introduction to Padrino

How is it different than Rails?

Has automatic administration interface generator -- inspired by Django:

● padrino g admin ○ generate admin application to be mounted inside main

application● padrino rake ar:migrate

○ for admin tables● padrino rake seed

○ create first admin account wizard● padrino generate admin_page model_name

○ adding a page to manage a new model● [more details: http://www.padrinorb.com/guides/basic-projects#generating-the-admin-section]

Page 12: Introduction to Padrino

padrino g admin

Page 13: Introduction to Padrino

1) Run 'padrino rake ar:migrate'2) Run 'padrino rake seed'3) Visit the admin panel in the browser at '/admin'

Page 14: Introduction to Padrino

Administration login page

Page 15: Introduction to Padrino

User editing form

Page 16: Introduction to Padrino

Why would someone choose to develop with Padrino VS Rails?From beginner...

● Sinatra is much easier to learn conceptually and in practice.

Page 17: Introduction to Padrino

Why would someone choose to develop with Padrino VS Rails?... to advanced.

● Once applications reach a certain size [...], Sinatra begins to break down without some imposed structure, feature extensions and a framework to bring things together.

○ Nathan Esquenazi

Page 18: Introduction to Padrino

Why would someone choose to develop with Padrino VS Rails?Other reasons why you might want to take a look at Padrino:

● Benchmarks performance of Padrino vs Rails (memory footprint, speed)● The ability to easily 'scale' up a Sinatra based app with more features

and functionalities with Padrino modules & embedded apps (app within an app)

● In Rails, Sinatra is already used sometimes as a platform for building 'plugins' and extending Rails functionality

● Agnostic generators that generate a variety of components for your project (orm's, js, renderers, tests, etc...)

● Admin interface application that can be generated into your existing padrino application ("... not just the scaffold, but the whole house" -- to paraphrase Django)

Page 19: Introduction to Padrino

Why would someone choose to develop with Padrino VS Rails?Selling Padrino:

● My motivation? I like to touch all pieces of my stack on my own, so I use a framework where I can easily look 'under the hood'.

○ Florian Gilcher

Page 20: Introduction to Padrino

@victorbstan

With help from the Padrino community&

Special thanks to the Toronto Ruby Brigade