Transcript Slide 1
Rails for the Ruby-Impaired John Paul Ashenfelter CTO/Transitionpoint 1 Why Build a Web App? Solve a (customer’s) problem 2 What Makes an Web App “Better”? Good Fast Cheap 3 The Holy Grail of Web Apps Build an application that solves a problem better, faster, and cheaper than anyone else 4 Keys to Successful Web Apps Follow standards Use best practices Reduce, reuse, recycle code Focus on quality and consistency Gracefully respond to change 5 Why Is Rails So Hot? Integrates/encourages best practices Inherently agile Keeps the framework out of the way Convention over configuration Self-contained Extracted from real-life applications Open source 6 Why Should I Care? Hits the ColdFusion sweet spot • • • • easy to use flexible fast (development and run-time) everything is built-in Java developers are adopting… and competing against you Lots of real-world momentum 7 Learning from Ruby on Rails Ruby and CFML are similar • • Scripting-oriented Dynamic (eg duck-typing) Rails and CF Frameworks are similar • • • Built for web applications MVC ORM options 8 Rails Components Active Record Web 2.0/AJAX migrations • Action Pack • • • • Action Controller Action View Action Mailer Active Support Rake • Prototype Script.alicio.us RJS Generators Plugins Servers • • Webrick mongrel 9 Code: Create a Rails app Create application skeleton • You’ll be using the command line Create the database • Not much config for dev/mysql Start server • • Server options Development modes Generate a scaffold 10 ActiveRecord Built-in ORM • • • CRUD validation filters transactions callbacks (16!) observers migrations 11 Code: Making the db invisible Conventions • • Names for keys, tables Magic columns Migrations ActiveRecord sugar • • has_XXX associations acts_as_XXX 12 Action Controller routing • REST flash filters • before, after, around caching cookie, session management 13 Code: Interacting with the user Default and custom routes The “flash” RESTful routes and methods 14 Action View templates • • • rhtml (embedded Ruby) rxml (Builder) rjs (AJAX) helpers • paging, form/field, formatting layouts partials and components 15 Code: Showing your work Templates, layouts, and partials Helpers Forms RJS (AJAX) 16 Code: Other Cool Stuff fixtures and YAML the vendor/ directory plugins capistrano JRuby 17 Rails Lessons for Web Frameworks 1. 2. 3. 4. Best practices are, well, best. Make the database invisible Easy things should be easy Testing is crucial… and should be easy 18 Call to Action for CF Frameworks More convention, less configuration Pick an ORM and integrate it • We need a migrations library Pick a AJAX library and integrate it Pick a testing library and integrate it • And automate the creation Don’t be afraid of the command line • Leverage Ant for automation where possible 19 Getting Started Resources Rails Environments • • • InstantRails (Windows) Locomotive (Mac) >gem install rails (any Ruby installation) Rails Editors • • • Eclipse with RadRails (radrails.org) Textmate (Mac) Other plugins… (Netbeans, Dreamweaver, etc.) Agile Web Development with Rails, 2nd ed. 20 Thanks/Questions John Paul Ashenfelter • • [email protected] http://www.transitionpoint.com Transitionpoint • • • Consulting Training Mentoring 21