SlideShare a Scribd company logo
1 of 41
Download to read offline
Building and Working with Static
Sites in Ruby on Rails
Ben Scofield
ben@viget.com
Senior Developer, Viget Labs




May 18, 2007




© Copyright 2007 Viget Labs, LLC – www.viget.com
2




Me

• 8 years building web apps (Perl, VBScript, C#,
  Java, PHP)
• Ruby and Rails for 2 years
• Tech Lead for Seth Godin’s Squidoo
• ben@viget.com




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
3




Viget Labs

• Full-service web design and development
  consultancy
• Three types of clients
         – Flash-based entertainment sites
         – Web 2.0 startups
         – Mid-sized, mostly static sites




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
4




“Static” sites

• Fully static: CMS
• Small scale: About Us, Contact Info
• Large scale: ACVA (funside.com)




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
5




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
6




Hybrid sites

• Distinct static and dynamic content (About Us)
• Intermingled static and dynamic content




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
7




THE PROBLEM

• Building a static site should be easy




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
8




And in PHP, it is

• Drop a file and see it run, even with embedded
  PHP code
• Use configuration files to route
       requests, set page-specific data,
       handle redirects, set page metadata...




Viget Labs
we build web business



May 18, 2007                © Copyright 2007 Viget Labs, LLC – www.viget.com
9




But in Rails?

• Actions for every view? sigh
• Actionless views? pfft

• and what about page-specific data?




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
10




So why bother with Rails?

• Less interesting: morale
• More interesting: productivity
         – task switching and specialization
• Most interesting: hybrid sites
         – current and future




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
11




Notes

• Error handling - ignore its absence
• Historical tour, Edge at the time




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
12




Solution 1: Rails on PHP

• Routing + Convention + Action + Caching =
  basic PHP?




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
13




Routing

• The beauty of the catch-all route:


• Declare all other routes explicitly!
  or namespace the catch-all:




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
14




Convention

• All templates under a single app/views
  subfolder
• Move as much to the layout as possible




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
15




Action




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
16




Caching

• Short and sweet: caches_page :show
• Rails caches under the request URI, not the
  controlller/action




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
17




Problems with Solution #1

• Manage page data in the views? pfft
• Manually expire the cache? pfft
• No support for redirects (site revisions)? pfft




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
18




Solution 2: Configuratron 2000

• Use configuration files to overcome the
  problems of Solution 1




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
19




navigation.yml

• Central management for pages, page data, and
  relationships




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
20




Memory’s cheap, right?

• Load it all into memory

• and pull it out when you need it




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
21




Caching

• Expire the entire cache when navigation.yml is
  updated




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
22




redirects.yml

• Use the redirect entry to find the new page




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
23




Problems with Solution #2

• Keeping it all in memory? pfft
• Upload new config files to change content? pfft
• All-or-nothing caching? pfft
• Not very Rails Wayish, is it?




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
24




Solution 3: CRUDification

• So what is Rails best at?
         – CRUD!


• Can we make static sites CRUDdier without
  creating a full-blown CMS?




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
25




Move it all to the DB...




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
26




Pages and Variables




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
27




Redirects




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
28




Sitemaps for nothing




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
29




Cascading Variables for Free




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
30




Web UI




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
31




Cache sweeping made easy




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
32




Problems with Solution #3

• Search
• Portability




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
33




Solution 4: Feed the DB

• Store page content in the DB
• Upload files or enter content through the UI
• Search with ... whatever




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
34




Reduce, Reuse, Recycle

• Package the framework for distribution




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
35




Question 1: To Engine or To Plugin?

• Engines
         – Cons: deprecated, people yell at you
• Plugins
         – Pros: everybody loves plugins!




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
36




Question 2: To Generate or To App?

• Generators
         – Pros: customized code
         – Cons: hard to update
• Plugin Applications
         – Pros: easy to update, fast start
         – Cons: possible conflicts




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
37




Plugin Applications

• Miniature Rails applications - controllers,
  models, and views
• Grant complete, self-contained functionality to
  another application




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
38




Using the framework

• Install the plugin-app
• Update config files
         – environment.rb and routes.rb
         – (optional) .htaccess and environment.rb
• Run the migrations
• Enjoy your newly more-static site!



Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
39




Key Points

• The catch-all route is the best kind of magic
• Play to Rails’ strengths
• Handle both large- and small-scale static sites




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com
40




                 Get the (alpha) framework at
                http://www.viget.com/railsconf/

                                Questions?
                        Ask ‘em now or email me at
                              ben@viget.com


Viget Labs
we build web business



May 18, 2007               © Copyright 2007 Viget Labs, LLC – www.viget.com
41




No questions, eh?

• Why even bother with this? Why not a CMS?
• Use content_for in the views to move more to
  the layout
• Plugems vs. engines vs. plugins?
• More about plugin-apps?




Viget Labs
we build web business



May 18, 2007            © Copyright 2007 Viget Labs, LLC – www.viget.com

More Related Content

Similar to Building and Working With Static Sites in Ruby on Rails

Migrating from PHP4 To PHP5 - Zend Webinar
Migrating from PHP4 To PHP5 - Zend WebinarMigrating from PHP4 To PHP5 - Zend Webinar
Migrating from PHP4 To PHP5 - Zend WebinarIvo Jansch
 
The Evolution of Hosting and What's Next with Cloud
The Evolution of Hosting and What's Next with CloudThe Evolution of Hosting and What's Next with Cloud
The Evolution of Hosting and What's Next with CloudJosh Ward
 
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...Atlassian
 
Enterprise PHP Development (Dutch PHP Conference 2008)
Enterprise PHP Development (Dutch PHP Conference 2008)Enterprise PHP Development (Dutch PHP Conference 2008)
Enterprise PHP Development (Dutch PHP Conference 2008)Ivo Jansch
 
Mockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaMockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaPatrick Reagan
 
Performance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsPerformance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsDenis Izmaylov
 
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG Enterprise
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG EnterpriseA Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG Enterprise
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG EnterpriseeG Innovations
 
JAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackJAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackzonathen
 
OneSpring: 5 Myths of Rich Internet Applications
OneSpring:  5 Myths of Rich Internet ApplicationsOneSpring:  5 Myths of Rich Internet Applications
OneSpring: 5 Myths of Rich Internet ApplicationsOneSpring LLC
 
High-Octane Dev Teams: Three Things You Can Do To Improve Code Quality
High-Octane Dev Teams: Three Things You Can Do To Improve Code QualityHigh-Octane Dev Teams: Three Things You Can Do To Improve Code Quality
High-Octane Dev Teams: Three Things You Can Do To Improve Code QualityAtlassian
 
Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsbyjs
 
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyImran Sayed
 
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity  and Performance Comparison AnalysisSOA Knowledge Kit, Developer Productivity  and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity and Performance Comparison AnalysisClever Moe
 
Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityDenis Izmaylov
 
Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]Chieh Kai Yang
 
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...Compuware APM
 

Similar to Building and Working With Static Sites in Ruby on Rails (20)

Migrating from PHP4 To PHP5 - Zend Webinar
Migrating from PHP4 To PHP5 - Zend WebinarMigrating from PHP4 To PHP5 - Zend Webinar
Migrating from PHP4 To PHP5 - Zend Webinar
 
The Evolution of Hosting and What's Next with Cloud
The Evolution of Hosting and What's Next with CloudThe Evolution of Hosting and What's Next with Cloud
The Evolution of Hosting and What's Next with Cloud
 
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
 
Keynote I
Keynote IKeynote I
Keynote I
 
Enterprise PHP Development (Dutch PHP Conference 2008)
Enterprise PHP Development (Dutch PHP Conference 2008)Enterprise PHP Development (Dutch PHP Conference 2008)
Enterprise PHP Development (Dutch PHP Conference 2008)
 
Symfony for non-techies
Symfony for non-techiesSymfony for non-techies
Symfony for non-techies
 
Web Design
Web DesignWeb Design
Web Design
 
Mockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaMockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. Mocha
 
Performance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsPerformance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React Applications
 
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG Enterprise
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG EnterpriseA Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG Enterprise
A Deep Dive Into Comprehensive Citrix & VDI Monitoring with eG Enterprise
 
Glass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.MiniGlass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.Mini
 
JAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stackJAMstack with gatsby, contentful and netlify aka the dream stack
JAMstack with gatsby, contentful and netlify aka the dream stack
 
OneSpring: 5 Myths of Rich Internet Applications
OneSpring:  5 Myths of Rich Internet ApplicationsOneSpring:  5 Myths of Rich Internet Applications
OneSpring: 5 Myths of Rich Internet Applications
 
High-Octane Dev Teams: Three Things You Can Do To Improve Code Quality
High-Octane Dev Teams: Three Things You Can Do To Improve Code QualityHigh-Octane Dev Teams: Three Things You Can Do To Improve Code Quality
High-Octane Dev Teams: Three Things You Can Do To Improve Code Quality
 
Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!Gatsby v2: Faster build times, guess.js, and more!
Gatsby v2: Faster build times, guess.js, and more!
 
Build Fast WordPress Site With Gatsby
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With Gatsby
 
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity  and Performance Comparison AnalysisSOA Knowledge Kit, Developer Productivity  and Performance Comparison Analysis
SOA Knowledge Kit, Developer Productivity and Performance Comparison Analysis
 
Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And Scalability
 
Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]Web.dev extended : What's new in Web [GDG Taichung]
Web.dev extended : What's new in Web [GDG Taichung]
 
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...
Achieving Peak User Experiences & Optimizing Web Performance - Load Testing, ...
 

More from Viget Labs

Building a Brand as Consumers Take Control
Building a Brand as Consumers Take ControlBuilding a Brand as Consumers Take Control
Building a Brand as Consumers Take ControlViget Labs
 
Branded Utility By Josh Chambers
Branded Utility By Josh ChambersBranded Utility By Josh Chambers
Branded Utility By Josh ChambersViget Labs
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingViget Labs
 
Women In Technology
Women In TechnologyWomen In Technology
Women In TechnologyViget Labs
 
9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did ItViget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsViget Labs
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityViget Labs
 
Changing Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentChanging Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentViget Labs
 
Dealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsDealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsViget Labs
 

More from Viget Labs (10)

Building a Brand as Consumers Take Control
Building a Brand as Consumers Take ControlBuilding a Brand as Consumers Take Control
Building a Brand as Consumers Take Control
 
Branded Utility By Josh Chambers
Branded Utility By Josh ChambersBranded Utility By Josh Chambers
Branded Utility By Josh Chambers
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Women In Technology
Women In TechnologyWomen In Technology
Women In Technology
 
9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It9 Tips to Profitability: How Squidoo Did It
9 Tips to Profitability: How Squidoo Did It
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Hows Haml?
Hows Haml?Hows Haml?
Hows Haml?
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Changing Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven DevelopmentChanging Your Mindset: Getting Started With Test-Driven Development
Changing Your Mindset: Getting Started With Test-Driven Development
 
Dealing With Legacy PHP Applications
Dealing With Legacy PHP ApplicationsDealing With Legacy PHP Applications
Dealing With Legacy PHP Applications
 

Recently uploaded

Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreNZSG
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfDanny Diep To
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxmbikashkanyari
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxappkodes
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in PhilippinesDavidSamuel525586
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers referencessuser2c065e
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024Adnet Communications
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environmentelijahj01012
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...ssuserf63bd7
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifeBhavana Pujan Kendra
 
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...ssuserf63bd7
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...Operational Excellence Consulting
 
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxGo for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxRakhi Bazaar
 
Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckHajeJanKamps
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Associazione Digital Days
 

Recently uploaded (20)

Jewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource CentreJewish Resources in the Family Resource Centre
Jewish Resources in the Family Resource Centre
 
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdfGUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
GUIDELINES ON USEFUL FORMS IN FREIGHT FORWARDING (F) Danny Diep Toh MBA.pdf
 
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptxThe-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
The-Ethical-issues-ghhhhhhhhjof-Byjus.pptx
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptx
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in Philippines
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers reference
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environment
 
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
Intermediate Accounting, Volume 2, 13th Canadian Edition by Donald E. Kieso t...
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in Life
 
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
Horngren’s Financial & Managerial Accounting, 7th edition by Miller-Nobles so...
 
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptxThe Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
 
WAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdfWAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdf
 
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptxGo for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
Go for Rakhi Bazaar and Pick the Latest Bhaiya Bhabhi Rakhi.pptx
 
Pitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deckPitch Deck Teardown: Xpanceo's $40M Seed deck
Pitch Deck Teardown: Xpanceo's $40M Seed deck
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
 

Building and Working With Static Sites in Ruby on Rails

  • 1. Building and Working with Static Sites in Ruby on Rails Ben Scofield ben@viget.com Senior Developer, Viget Labs May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 2. 2 Me • 8 years building web apps (Perl, VBScript, C#, Java, PHP) • Ruby and Rails for 2 years • Tech Lead for Seth Godin’s Squidoo • ben@viget.com Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 3. 3 Viget Labs • Full-service web design and development consultancy • Three types of clients – Flash-based entertainment sites – Web 2.0 startups – Mid-sized, mostly static sites Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 4. 4 “Static” sites • Fully static: CMS • Small scale: About Us, Contact Info • Large scale: ACVA (funside.com) Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 5. 5 Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 6. 6 Hybrid sites • Distinct static and dynamic content (About Us) • Intermingled static and dynamic content Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 7. 7 THE PROBLEM • Building a static site should be easy Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 8. 8 And in PHP, it is • Drop a file and see it run, even with embedded PHP code • Use configuration files to route requests, set page-specific data, handle redirects, set page metadata... Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 9. 9 But in Rails? • Actions for every view? sigh • Actionless views? pfft • and what about page-specific data? Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 10. 10 So why bother with Rails? • Less interesting: morale • More interesting: productivity – task switching and specialization • Most interesting: hybrid sites – current and future Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 11. 11 Notes • Error handling - ignore its absence • Historical tour, Edge at the time Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 12. 12 Solution 1: Rails on PHP • Routing + Convention + Action + Caching = basic PHP? Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 13. 13 Routing • The beauty of the catch-all route: • Declare all other routes explicitly! or namespace the catch-all: Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 14. 14 Convention • All templates under a single app/views subfolder • Move as much to the layout as possible Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 15. 15 Action Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 16. 16 Caching • Short and sweet: caches_page :show • Rails caches under the request URI, not the controlller/action Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 17. 17 Problems with Solution #1 • Manage page data in the views? pfft • Manually expire the cache? pfft • No support for redirects (site revisions)? pfft Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 18. 18 Solution 2: Configuratron 2000 • Use configuration files to overcome the problems of Solution 1 Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 19. 19 navigation.yml • Central management for pages, page data, and relationships Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 20. 20 Memory’s cheap, right? • Load it all into memory • and pull it out when you need it Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 21. 21 Caching • Expire the entire cache when navigation.yml is updated Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 22. 22 redirects.yml • Use the redirect entry to find the new page Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 23. 23 Problems with Solution #2 • Keeping it all in memory? pfft • Upload new config files to change content? pfft • All-or-nothing caching? pfft • Not very Rails Wayish, is it? Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 24. 24 Solution 3: CRUDification • So what is Rails best at? – CRUD! • Can we make static sites CRUDdier without creating a full-blown CMS? Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 25. 25 Move it all to the DB... Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 26. 26 Pages and Variables Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 27. 27 Redirects Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 28. 28 Sitemaps for nothing Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 29. 29 Cascading Variables for Free Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 30. 30 Web UI Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 31. 31 Cache sweeping made easy Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 32. 32 Problems with Solution #3 • Search • Portability Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 33. 33 Solution 4: Feed the DB • Store page content in the DB • Upload files or enter content through the UI • Search with ... whatever Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 34. 34 Reduce, Reuse, Recycle • Package the framework for distribution Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 35. 35 Question 1: To Engine or To Plugin? • Engines – Cons: deprecated, people yell at you • Plugins – Pros: everybody loves plugins! Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 36. 36 Question 2: To Generate or To App? • Generators – Pros: customized code – Cons: hard to update • Plugin Applications – Pros: easy to update, fast start – Cons: possible conflicts Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 37. 37 Plugin Applications • Miniature Rails applications - controllers, models, and views • Grant complete, self-contained functionality to another application Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 38. 38 Using the framework • Install the plugin-app • Update config files – environment.rb and routes.rb – (optional) .htaccess and environment.rb • Run the migrations • Enjoy your newly more-static site! Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 39. 39 Key Points • The catch-all route is the best kind of magic • Play to Rails’ strengths • Handle both large- and small-scale static sites Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 40. 40 Get the (alpha) framework at http://www.viget.com/railsconf/ Questions? Ask ‘em now or email me at ben@viget.com Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com
  • 41. 41 No questions, eh? • Why even bother with this? Why not a CMS? • Use content_for in the views to move more to the layout • Plugems vs. engines vs. plugins? • More about plugin-apps? Viget Labs we build web business May 18, 2007 © Copyright 2007 Viget Labs, LLC – www.viget.com