End to-End CoffeeScript

End-to-End
  CoffeeScript
Presented by Trevor Burnham
     at RailsConf 2011
Part I
CoffeeScript!?!?
What is CoffeeScript?
Do you have to use it?
But seriously...
Things I’ll cover today:

A brief primer on the CoffeeScript language
How it works with the Rails 3.1 asset
pipeline
Running the same JS/CS code on both the
client and the server
And things I won’t:

The CoffeeScript language in depth (that
would take a whole book... available at
http://coffeescript-book.com)
Sprockets 2 (#=
require
foo)

jQuery UJS ($.rails)
CoffeeScript crash course



 “Dash rocket” instead of function

 Semantic whitespace instead of {}

 Implicit parentheses, implicit var scoping
Awesome goodies for
      Rubyists


Postfix if/unless

Implicit returns

String interpolations
Things that feel weird to
        Rubyists



Parentheses are not optional on functions
with no arguments
It’s just JavaScript™
Things that feel weird to
     JavaScripters


CoffeeScript’s of is JavaScript’s in

CoffeeScript’s in is Python’s in

CoffeeScript’s == is JavaScript’s ===
Tradeoffs

Debugging (will get better, but currently
kind of a pain)
Changing versions (though it’s been
pretty stable for the last 5 months)
Less documentation (but there is a
book from PragProg...)
Even so!

After only a week of using CoffeeScript,
I felt more productive than I ever had in
JavaScript.
The community is awesome.
Learning CoffeeScript might make you think
more deeply about JavaScript.
Part II
CoffeeScript in Rails 3.1
Let’s make a Rails app!

rails
new
EndToEnd
cd
EndToEnd
rails
generate
controller
User
signup

Clone the repo if you want to follow along...
http://github.com/TrevorBurnham/EndToEnd)
JavaScripts are assets
New in Rails 3.1, generate
controller gives
us a CoffeeScript file automatically:
Compound extensions

.html.erb & .html.haml → HTML

.css.scss & .css.sass → CSS

.js.coffee → JavaScript

Want to use a different format? Just rename!
application.js → application.js.coffee
Compound extensions
Stylesheets and JavaScripts are automatically
concatenated by Sprockets 2, even in development:




All the CSS and JS is loaded on every page, so it’s
still up to you to isolate controller-specific
functionality.
Building a sign-up box
Adding JS validations
Great, but...
Client-side validations are just there to
provide a friendlier user experience. What
really matters are server-side validations.
Traditionally, we’d do this by using
ActiveRecord, repeating much of the work
we just did...
But there’s another way!
Server-side JavaScript!
  (And CoffeeScript)
If you’ve got coffee‐script in your
Gemfile, then you’ve already got ExecJS:
https://github.com/sstephenson/execjs
It uses the best available JS environment on
your system. Use therubyracer (or
therubyracer‐heroku) for maximum
portability.
No need to rewrite the
 same validation code!
ExecJS lets us turn our CoffeeScript
validation code into a Ruby object:
A small taste of
       what’s to come
Future plugins will make the server-side JS
process smoother in Rails
With jsdom, you can do practically anything
that you could do with client-side JS
(including manipulating HTML with jQuery!)
Validation, templating... anything you’re
duplicating can be done as end-to-end JS.
How can you become a
  CoffeeScript ninja?
Official site, great overview:
http://coffeescript.org
Nice screencast:
http://peepcode.com/products/coffeescript
Totally unbiased book recommendation:
http://coffeescript-book.com
Thanks
        Questions?
trevorburnham@gmail.com
1 of 26

Recommended

CoffeeScript Design Patterns by
CoffeeScript Design PatternsCoffeeScript Design Patterns
CoffeeScript Design PatternsTrevorBurnham
4.8K views64 slides
Happy Programming with CoffeeScript by
Happy Programming with CoffeeScriptHappy Programming with CoffeeScript
Happy Programming with CoffeeScriptEddie Kao
11K views132 slides
CoffeeScript presentation by
CoffeeScript presentationCoffeeScript presentation
CoffeeScript presentationJohn Lynch
1.6K views19 slides
Advanced JavaScript build pipelines using Gulp.js by
Advanced JavaScript build pipelines using Gulp.jsAdvanced JavaScript build pipelines using Gulp.js
Advanced JavaScript build pipelines using Gulp.jsStefan Baumgartner
1.4K views67 slides
Plumbin Pipelines - A Gulp.js workshop by
Plumbin Pipelines - A Gulp.js workshopPlumbin Pipelines - A Gulp.js workshop
Plumbin Pipelines - A Gulp.js workshopStefan Baumgartner
778 views109 slides
CoffeeScript, An Introduction for Nodejs developers by
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersMehdi Valikhani
3.7K views49 slides

More Related Content

What's hot

Lessons Learnt in 2009 by
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009pratiknaik
1.8K views98 slides
Ruby On Rails Introduction by
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails IntroductionThomas Fuchs
57K views153 slides
DSLs Internas e Ruby by
DSLs Internas e RubyDSLs Internas e Ruby
DSLs Internas e RubyFabio Kung
716 views25 slides
Introduce cucumber by
Introduce cucumberIntroduce cucumber
Introduce cucumberBachue Zhou
1.5K views32 slides
Drupal + selenium by
Drupal + seleniumDrupal + selenium
Drupal + seleniumhernanibf
1.9K views18 slides
node.js - Fast event based web application development by
node.js - Fast event based web application developmentnode.js - Fast event based web application development
node.js - Fast event based web application developmentopenForce Information Technology GesmbH
1.9K views21 slides

What's hot(20)

Lessons Learnt in 2009 by pratiknaik
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
pratiknaik1.8K views
Ruby On Rails Introduction by Thomas Fuchs
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
Thomas Fuchs57K views
DSLs Internas e Ruby by Fabio Kung
DSLs Internas e RubyDSLs Internas e Ruby
DSLs Internas e Ruby
Fabio Kung716 views
Introduce cucumber by Bachue Zhou
Introduce cucumberIntroduce cucumber
Introduce cucumber
Bachue Zhou1.5K views
Drupal + selenium by hernanibf
Drupal + seleniumDrupal + selenium
Drupal + selenium
hernanibf1.9K views
JSConf US 2014: Building Isomorphic Apps by Spike Brehm
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
Spike Brehm5.4K views
Bundler is the Best by dead_arm
Bundler is the BestBundler is the Best
Bundler is the Best
dead_arm893 views
The Peanut Butter Cup of Web-dev: Plack and single page web apps by John Anderson
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
John Anderson545 views
Isomorphic App Development with Ruby and Volt - Rubyconf2014 by ryanstout
Isomorphic App Development with Ruby and Volt - Rubyconf2014Isomorphic App Development with Ruby and Volt - Rubyconf2014
Isomorphic App Development with Ruby and Volt - Rubyconf2014
ryanstout27.6K views
The Asynchronous Pattern (for beginners) by Andrea Tino
The Asynchronous Pattern (for beginners)The Asynchronous Pattern (for beginners)
The Asynchronous Pattern (for beginners)
Andrea Tino357 views
Let's talk ChatOps - Hubot with less CoffeeScript by SarahKowalik
Let's talk ChatOps - Hubot with less CoffeeScriptLet's talk ChatOps - Hubot with less CoffeeScript
Let's talk ChatOps - Hubot with less CoffeeScript
SarahKowalik565 views
Puppet at Pinterest by Puppet
Puppet at PinterestPuppet at Pinterest
Puppet at Pinterest
Puppet6.5K views
Concurrent Ruby Application Servers by Lin Jen-Shin
Concurrent Ruby Application ServersConcurrent Ruby Application Servers
Concurrent Ruby Application Servers
Lin Jen-Shin5.8K views
Volt 2015 by ryanstout
Volt 2015Volt 2015
Volt 2015
ryanstout599 views
Deploying a Location-Aware Ember Application by Ben Limmer
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember Application
Ben Limmer8.1K views
TechDays - IronRuby by Ben Hall
TechDays - IronRubyTechDays - IronRuby
TechDays - IronRuby
Ben Hall1K views

Viewers also liked

E field disk by
E field diskE field disk
E field diskFFMdeMul
940 views11 slides
Cubmaster's Toolbox by
Cubmaster's ToolboxCubmaster's Toolbox
Cubmaster's ToolboxJohn DeGroote
3.1K views36 slides
Nz Marine Cluster May 12 Report by
Nz Marine Cluster May 12 ReportNz Marine Cluster May 12 Report
Nz Marine Cluster May 12 ReportBen Mayson
1.3K views35 slides
Presentation1 by
Presentation1Presentation1
Presentation1sophiesharkey
140 views4 slides
Presentation1 by
Presentation1Presentation1
Presentation1sophiesharkey
160 views4 slides
The CoffeeScript Edge by
The CoffeeScript EdgeThe CoffeeScript Edge
The CoffeeScript EdgeTrevorBurnham
1.7K views157 slides

Viewers also liked(20)

E field disk by FFMdeMul
E field diskE field disk
E field disk
FFMdeMul940 views
Nz Marine Cluster May 12 Report by Ben Mayson
Nz Marine Cluster May 12 ReportNz Marine Cluster May 12 Report
Nz Marine Cluster May 12 Report
Ben Mayson1.3K views
The CoffeeScript Edge by TrevorBurnham
The CoffeeScript EdgeThe CoffeeScript Edge
The CoffeeScript Edge
TrevorBurnham1.7K views
2013 10-22 internet-arriskuak_andramendi_eu by Urko Zurutuza
2013 10-22 internet-arriskuak_andramendi_eu2013 10-22 internet-arriskuak_andramendi_eu
2013 10-22 internet-arriskuak_andramendi_eu
Urko Zurutuza264 views
Internet-en, ze irudi ari naiz ematen? by Urko Zurutuza
Internet-en, ze irudi ari naiz ematen?Internet-en, ze irudi ari naiz ematen?
Internet-en, ze irudi ari naiz ematen?
Urko Zurutuza409 views
'Decisions For Life' -Project by wageindicator
'Decisions For Life' -Project'Decisions For Life' -Project
'Decisions For Life' -Project
wageindicator598 views
Nz Marine Cluster May 12 Ppt by Ben Mayson
Nz Marine Cluster May 12 PptNz Marine Cluster May 12 Ppt
Nz Marine Cluster May 12 Ppt
Ben Mayson1.5K views
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D. by guestc179d8
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
guestc179d86K views
Sane Async Patterns by TrevorBurnham
Sane Async PatternsSane Async Patterns
Sane Async Patterns
TrevorBurnham14.6K views
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit... by guestc179d8
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
guestc179d82.6K views
Case Studies In Stroke by guestc179d8
Case Studies In StrokeCase Studies In Stroke
Case Studies In Stroke
guestc179d820.4K views
Internet arriskuak bidegoian_2011-09-22 by Urko Zurutuza
Internet arriskuak bidegoian_2011-09-22Internet arriskuak bidegoian_2011-09-22
Internet arriskuak bidegoian_2011-09-22
Urko Zurutuza451 views
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket by Empowered Presentations
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocketTOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
El tiempo by Juan Diaz
El tiempoEl tiempo
El tiempo
Juan Diaz156 views

Similar to End to-End CoffeeScript

Writing Bullet-Proof Javascript: By Using CoffeeScript by
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptSusan Potter
1.5K views13 slides
CoffeeScript the Awesome by
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the AwesomeJames Hughes
776 views25 slides
Coffee scripts with rails by
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with railsDevilal Dheer
429 views14 slides
Smooth CoffeeScript by
Smooth CoffeeScriptSmooth CoffeeScript
Smooth CoffeeScriptMichael Scovetta
7.2K views214 slides
Overview of CoffeeScript by
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScriptAniruddha Chakrabarti
767 views26 slides
Coffeescript unfancy javascript by
Coffeescript unfancy javascriptCoffeescript unfancy javascript
Coffeescript unfancy javascriptDimitris Tsironis
808 views18 slides

Similar to End to-End CoffeeScript(20)

Writing Bullet-Proof Javascript: By Using CoffeeScript by Susan Potter
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScript
Susan Potter1.5K views
CoffeeScript the Awesome by James Hughes
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the Awesome
James Hughes776 views
Coffee scripts with rails by Devilal Dheer
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with rails
Devilal Dheer429 views
Front-End Engineering 101 by Milan Korsos
Front-End Engineering 101Front-End Engineering 101
Front-End Engineering 101
Milan Korsos1.1K views
TorqueBox - Ruby Hoedown 2011 by Lance Ball
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
Lance Ball696 views
One does not simply "Upgrade to Rails 3" by testflyjets
One does not simply "Upgrade to Rails 3"One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"
testflyjets1.2K views
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em... by Paul Jensen
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen679 views
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov by Michael Kimathi
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Michael Kimathi216 views
appborg, coffeesurgeon, moof, logging-system by endian7000
appborg, coffeesurgeon, moof, logging-systemappborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-system
endian7000167 views
Rails 3.1 by Lori Olson
Rails 3.1Rails 3.1
Rails 3.1
Lori Olson1.2K views
CoffeeScript: The Good Parts by C4Media
CoffeeScript: The Good PartsCoffeeScript: The Good Parts
CoffeeScript: The Good Parts
C4Media1.3K views

Recently uploaded

Measuring User on the web with the core web vitals - by @theafolayan.pptx by
Measuring User on the web with the core web vitals - by @theafolayan.pptxMeasuring User on the web with the core web vitals - by @theafolayan.pptx
Measuring User on the web with the core web vitals - by @theafolayan.pptxOluwaseun Raphael Afolayan
14 views13 slides
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Moses Kemibaro
38 views38 slides
This talk was not generated with ChatGPT: how AI is changing science by
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing scienceElena Simperl
34 views13 slides
Business Analyst Series 2023 - Week 4 Session 7 by
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
152 views31 slides
Netmera Presentation.pdf by
Netmera Presentation.pdfNetmera Presentation.pdf
Netmera Presentation.pdfMustafa Kuğu
22 views50 slides
Business Analyst Series 2023 - Week 4 Session 8 by
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
180 views13 slides

Recently uploaded(20)

Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro38 views
This talk was not generated with ChatGPT: how AI is changing science by Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl34 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10152 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10180 views
"Package management in monorepos", Zoltan Kochan by Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays37 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash171 views
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views
Optimizing Communication to Optimize Human Behavior - LCBM by Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar39 views
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」 by PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
AIM102-S_Cognizant_CognizantCognitive by PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford23 views
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada46 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf by ThomasBronack
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdfBronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
ThomasBronack31 views

End to-End CoffeeScript

  • 1. End-to-End CoffeeScript Presented by Trevor Burnham at RailsConf 2011
  • 4. Do you have to use it?
  • 6. Things I’ll cover today: A brief primer on the CoffeeScript language How it works with the Rails 3.1 asset pipeline Running the same JS/CS code on both the client and the server
  • 7. And things I won’t: The CoffeeScript language in depth (that would take a whole book... available at http://coffeescript-book.com) Sprockets 2 (#=
require
foo) jQuery UJS ($.rails)
  • 8. CoffeeScript crash course “Dash rocket” instead of function Semantic whitespace instead of {} Implicit parentheses, implicit var scoping
  • 9. Awesome goodies for Rubyists Postfix if/unless Implicit returns String interpolations
  • 10. Things that feel weird to Rubyists Parentheses are not optional on functions with no arguments It’s just JavaScript™
  • 11. Things that feel weird to JavaScripters CoffeeScript’s of is JavaScript’s in CoffeeScript’s in is Python’s in CoffeeScript’s == is JavaScript’s ===
  • 12. Tradeoffs Debugging (will get better, but currently kind of a pain) Changing versions (though it’s been pretty stable for the last 5 months) Less documentation (but there is a book from PragProg...)
  • 13. Even so! After only a week of using CoffeeScript, I felt more productive than I ever had in JavaScript. The community is awesome. Learning CoffeeScript might make you think more deeply about JavaScript.
  • 15. Let’s make a Rails app! rails
new
EndToEnd cd
EndToEnd rails
generate
controller
User
signup Clone the repo if you want to follow along... http://github.com/TrevorBurnham/EndToEnd)
  • 16. JavaScripts are assets New in Rails 3.1, generate
controller gives us a CoffeeScript file automatically:
  • 17. Compound extensions .html.erb & .html.haml → HTML .css.scss & .css.sass → CSS .js.coffee → JavaScript Want to use a different format? Just rename! application.js → application.js.coffee
  • 18. Compound extensions Stylesheets and JavaScripts are automatically concatenated by Sprockets 2, even in development: All the CSS and JS is loaded on every page, so it’s still up to you to isolate controller-specific functionality.
  • 21. Great, but... Client-side validations are just there to provide a friendlier user experience. What really matters are server-side validations. Traditionally, we’d do this by using ActiveRecord, repeating much of the work we just did... But there’s another way!
  • 22. Server-side JavaScript! (And CoffeeScript) If you’ve got coffee‐script in your Gemfile, then you’ve already got ExecJS: https://github.com/sstephenson/execjs It uses the best available JS environment on your system. Use therubyracer (or therubyracer‐heroku) for maximum portability.
  • 23. No need to rewrite the same validation code! ExecJS lets us turn our CoffeeScript validation code into a Ruby object:
  • 24. A small taste of what’s to come Future plugins will make the server-side JS process smoother in Rails With jsdom, you can do practically anything that you could do with client-side JS (including manipulating HTML with jQuery!) Validation, templating... anything you’re duplicating can be done as end-to-end JS.
  • 25. How can you become a CoffeeScript ninja? Official site, great overview: http://coffeescript.org Nice screencast: http://peepcode.com/products/coffeescript Totally unbiased book recommendation: http://coffeescript-book.com
  • 26. Thanks Questions? trevorburnham@gmail.com