Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mid-Hudson Valley Linux Users Group Ruby on Rails Web Development is Fun Again MHVLUG Meeting Jan 7 th 2009 Sean Dague sean.dague.net.

Similar presentations


Presentation on theme: "Mid-Hudson Valley Linux Users Group Ruby on Rails Web Development is Fun Again MHVLUG Meeting Jan 7 th 2009 Sean Dague sean.dague.net."— Presentation transcript:

1 Mid-Hudson Valley Linux Users Group Ruby on Rails Web Development is Fun Again MHVLUG Meeting Jan 7 th 2009 Sean Dague sean.dague.net

2 Mid-Hudson Valley Linux Users Group Challenges of Tonight's Talk Installing Rails Creating a Scaffold AJAX Effects Deploying with Passenger ActiveRecord Basics Validators ActiveSuppor t MVC ActiveRecord Magic Migrations Unit Testing REST Web Services RESTful Authentication Layout s RJS Templates XML Builder Object Relationships acts_as_tre e acts_as_list Wrapping Legacy Databases DateTime mixins ActiveMaile r Rails Plugins Git Support LDAP Support xml-rpc background.rb

3 Mid-Hudson Valley Linux Users Group Where did it come from? "37Signals is “sexy” - one of its founders is the Scandinavian rockstar behind Ruby on Rails, David Heinemeier Hansson. On the tech industry sexometer, 37Signals is like Spinal Tap- they have a special cool amplifier that goes up to 11." - James Governor, Redmonk.com

4 Mid-Hudson Valley Linux Users Group The Rails Motto DRYDRY on't epeat ourself

5 Mid-Hudson Valley Linux Users Group Model / View / Controller pattern

6 Mid-Hudson Valley Linux Users Group Nuts and Bolts I promise we'll get to fun stuff shortly

7 Mid-Hudson Valley Linux Users Group Rails Installation ● It may come with your distribution – Using that often makes the most sense – Ubuntu 8.10 ships rails 2.1.0 - There is a layouts bug which is fixed in 2.1.2 ● Instant Rails - easy on Windows ● And yes, it works great on Mac as well

8 Mid-Hudson Valley Linux Users Group Installing Rails on Ubuntu # gem install rails -v "=2.1.2" Successfully installed activesupport-2.1.2 Successfully installed activerecord-2.1.2 Successfully installed actionpack-2.1.2 Successfully installed actionmailer-2.1.2 Successfully installed activeresource-2.1.2 Successfully installed rails-2.1.2... (documentation installation)

9 Mid-Hudson Valley Linux Users Group The Sample Application MHVLUG Event Calendar...created live

10 Mid-Hudson Valley Linux Users Group Some Ruby-isms you'll see ● :event is 'event' - ':' auto quotes a string ● parens are not required if unambiguous – debugger - is a function – link_to 'Show', event - is a function with 2 params ● @event is not an array, it is an instance scope ● respond_to do |format|... ● end ● respond_to returns an iterator, the do block is called once for every item in the iterator. format is the object of that iteration.

11 Mid-Hudson Valley Linux Users Group Rails loves that escaping Event.find(:first, :conditions => ["name=?", name]) Why do we care?

12 Mid-Hudson Valley Linux Users Group

13 Your First Rails Application # rails -d sqlite3 mhvlug-event... # cd mhvlug-event #./script/server => Booting WEBrick... => Rails 2.1.2 application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options [2008-12-27 11:53:19] INFO WEBrick 1.3.1 [2008-12-27 11:53:19] INFO ruby 1.8.7 (2008-08-11) [i486-linux] [2008-12-27 11:53:19] INFO WEBrick::HTTPServer#start: pid=27722 port=3000

14 Mid-Hudson Valley Linux Users Group Creating Your First Model/Scaffold #./script/generate scaffold event name:string description:text location:string start:datetime end:datetime... # rake db:migrate

15 Mid-Hudson Valley Linux Users Group Exploring that Scaffold

16 Mid-Hudson Valley Linux Users Group Flavor of Rails class Project < ActiveRecord::Base belongs_to :portfolio has_one :project_manager has_many :milestones has_many :deliverables, :through => :milestones validates_presence_of :name, :description validates_acceptance_of :non_disclosure_agreement validates_uniqueness_of :short_name end

17 Mid-Hudson Valley Linux Users Group Migrations

18 Mid-Hudson Valley Linux Users Group Adding Layout

19 Mid-Hudson Valley Linux Users Group Rails Conventions ● Objects are singular, database tables are plural – Person objects stored in people table ● Database tables have primary key named id, which is an auto incrementing integer ● Foreign keys defined by object_id.

20 Mid-Hudson Valley Linux Users Group Buy These Books!

21 Mid-Hudson Valley Linux Users Group NetBeans - Rails IDE

22 Mid-Hudson Valley Linux Users Group Advanced Topics ● Wrapping Legacy Data ● Adding User Authentication - restful_authentication ● Consuming Web Services - Active Resource ● Deployment - passenger / aka mod_rails ● Rails Debugger ● Rails Console ● restful_authentication_tutorial

23 Mid-Hudson Valley Linux Users Group Things I love about Rails ● Migrations ● Layouts ● Deep REST integration ● Secure by default ● Built in testing ● Rails is not synthetic ● 30 minutes to add a new feature


Download ppt "Mid-Hudson Valley Linux Users Group Ruby on Rails Web Development is Fun Again MHVLUG Meeting Jan 7 th 2009 Sean Dague sean.dague.net."

Similar presentations


Ads by Google