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

SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 MonthsSEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 MonthsIndeedSEO
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceDamini Dixit
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizharallensay1
 
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLWhitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...amitlee9823
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxWorkforce Group
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noidadlhescort
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon investment
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwaitdaisycvs
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Sheetaleventcompany
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...amitlee9823
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Falcon Invoice Discounting
 

Recently uploaded (20)

(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 MonthsSEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLWhitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
 

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