SlideShare a Scribd company logo
1 of 20
Download to read offline
Get started with Rails 3

             by
         Karmen Blake



 Rails 3: Overview

 RVM: Ruby Version Manager

 Basic Rails 3 App
Rails 3: Overview
Rails 3: Overview

Merb
  Fast
  Lightweight
  Powerful = featureful, flexible, and extensible


Rails
   Popular
   Easy to get started
   Opinionated
   Large ecosystem: books, blogs, screencasts, community
Rails 3: Overview
Ruby Version Manager (RVM)

Why?
 For me, I've been attached to Ruby 1.8.6
 for a long time. Mostly because it is stable
 and legacy projects I work on rely on it.
 Lots of gems installed that just work.
 Rails 3 requires 1.8.7 and above! Doh!!!
Ruby Version Manager (RVM)

Command line tool which allows us to
easily install, manage and work with
multiple ruby environments (and
associated gems).
Ruby Version Manager (RVM)
Ruby Version Manager (RVM)

Installation:

> mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git
clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm
&& ./install

That is a long command, eh.

You might want to go here and read for yourself: http://rvm.
beginrescueend.com/rvm/install/

Follow instructions after that which involves adding a line to
your bash profile.
Installing Rails Using RVM


> rvm install 1.9.1 (or 1.8.7 or 1.9.2)
> rvm 1.9.1 --default (uses 1.9.1 on newly opened terminal windows)
> curl -L http://rvm.beginrescueend.com/gemsets/rails3.gems -o rails3.gems
> rvm gemset import rails3.gems
> rails -v (should show Rails 3 beta)

You may have to install sqlite/mysql and associated gems. For
example,

> gem install sqlite3-ruby
Ruby Version Manager (RVM)

A few more things:

To use system ruby installed by default:
> rvm system --default

See installed rubies:
> rvm list

Named Gem Sets
RVM not only isolates different ruby installations it also lets you
isolate different gem sets. Thus you can mix and match rubies
and gem sets. Amazing!! More here: http://rvm.
beginrescueend.com/gemsets/basics/
Introduction to Rails 3

Generate a Rails 3 app
> rails generate app_name
> rails g app_name

script/rails is the only thing in there!

Generate scaffold
> rails g scaffold Post title:string body:text
> rake db:migrate

Start server
> rails server
> rails s
Introduction to Rails 3

Console
> rails console
> rails c

Database Console
> rails dbconsole
> rails db
Introduction to Rails 3

ActiveRecord Validation

Rails 2 - separate validations
validates_presence_of :title
validates_uniqueness_of :title
validates_length_of :title, :maximum => 35


Rails 3 - puts validations together for a field
validates :title, :presence => true,
             :uniqueness => true,
             :length => {:maximum => 35}
Introduction to Rails 3

ActiveRecord Query Interface

New API
  where(:conditions)
  having(:conditions)
  select
  group
  order
  limit
  includes(:include)
  and more...
Introduction to Rails 3

ActiveRecord Query Interface

Why New API?

Chainability!!!! No not gold chains. :)

Post.where(:title => "test")
Post.where(:title => "test").order("created_at DESC")
Post.order("created_at").limit(10)
Post.where("created_at <= ?", Time.now).includes(:comments)
Introduction to Rails 3

ActiveRecord Query Interface

Lazy Loading

posts = Post.all
Returns a ActiveRelation object containing information about query.

As soon as you access ActiveRelation object, for example in view,
then call gets executed to db. Nice for fragment caching, etc.

<% posts.each do |post| %>
  <li><%= post.title %></li>
<% end %>
Introduction to Rails 3

More Rails 3 Goodies:

Router

Mailer

Unobtrusive Javascript

...

Will have to wait for another presentation. :)
Introduction to Rails 3

All you want to know and more about Rails 3

   http://mediumexposure.com/rails-3-reading-material/
   http://www.rubyinside.com/rails-3-0-beta-links-2966.html
   http://railslove.com/weblog/2010/02/02/on-the-way-to-rails-
   3-a-link-list/
   http://railsnotes.com/rails-3/
References

 http://www.slideshare.net/GreggPollack/rails-3-beautiful-
 code-3219240
 http://guides.rails.info/getting_started.html
 http://railscasts.com/episodes/202-active-record-queries-in-
 rails-3
 http://m.onkey.org/2010/1/22/active-record-query-interface
 http://rvm.beginrescueend.com/
 pik
     rvm tool on windows, I've never used though
     http://github.com/vertiginous/pik
Karmen Blake

http://www.dudeblake.com
http://blog.dudeblake.com
http://twitter.com/kblake
http://github.com/kblake

More Related Content

What's hot

Cloudera amazon-ec2
Cloudera amazon-ec2Cloudera amazon-ec2
Cloudera amazon-ec2Randy Zwitch
 
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and ScalaWriting highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and Scalajfarcand
 
Activemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataActivemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataRamakrishna Narkedamilli
 
The Atmosphere Framework
The Atmosphere FrameworkThe Atmosphere Framework
The Atmosphere Frameworkjfarcand
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatEgnyte
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in muleMohammed246
 
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูลบทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูลPriew Chakrit
 
introduction to Tomcat Apache
introduction to Tomcat Apache introduction to Tomcat Apache
introduction to Tomcat Apache Pushpendra Tyagi
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nirmal Mehta
 
Integrating Tomcat And Apache On Windows
Integrating Tomcat And Apache On WindowsIntegrating Tomcat And Apache On Windows
Integrating Tomcat And Apache On WindowsMohanraj Nagasamy
 
Apache ds building_from_source
Apache ds building_from_sourceApache ds building_from_source
Apache ds building_from_sourcemervettt
 
Squid for Load-Balancing & Cache-Proxy ~ A techXpress Guide
Squid for Load-Balancing & Cache-Proxy ~ A techXpress GuideSquid for Load-Balancing & Cache-Proxy ~ A techXpress Guide
Squid for Load-Balancing & Cache-Proxy ~ A techXpress GuideAbhishek Kumar
 

What's hot (16)

Cloudera amazon-ec2
Cloudera amazon-ec2Cloudera amazon-ec2
Cloudera amazon-ec2
 
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and ScalaWriting highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
 
Activemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataActivemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker data
 
The Atmosphere Framework
The Atmosphere FrameworkThe Atmosphere Framework
The Atmosphere Framework
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache Tomcat
 
Apache TomEE - Tomcat with a kick
Apache TomEE  - Tomcat with a kickApache TomEE  - Tomcat with a kick
Apache TomEE - Tomcat with a kick
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in mule
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
 
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูลบทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
 
Docker 1.12 and SwarmKit
Docker 1.12 and SwarmKitDocker 1.12 and SwarmKit
Docker 1.12 and SwarmKit
 
Simple groovy example in mule
Simple groovy example in muleSimple groovy example in mule
Simple groovy example in mule
 
introduction to Tomcat Apache
introduction to Tomcat Apache introduction to Tomcat Apache
introduction to Tomcat Apache
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
 
Integrating Tomcat And Apache On Windows
Integrating Tomcat And Apache On WindowsIntegrating Tomcat And Apache On Windows
Integrating Tomcat And Apache On Windows
 
Apache ds building_from_source
Apache ds building_from_sourceApache ds building_from_source
Apache ds building_from_source
 
Squid for Load-Balancing & Cache-Proxy ~ A techXpress Guide
Squid for Load-Balancing & Cache-Proxy ~ A techXpress GuideSquid for Load-Balancing & Cache-Proxy ~ A techXpress Guide
Squid for Load-Balancing & Cache-Proxy ~ A techXpress Guide
 

Viewers also liked

NJEA Podcasting Workshop
NJEA Podcasting WorkshopNJEA Podcasting Workshop
NJEA Podcasting Workshopheinricb
 
Secure Voting
Secure VotingSecure Voting
Secure VotingBen Adida
 
BeamAuth - Two-Factor Web Authentication with a Bookmark
BeamAuth - Two-Factor Web Authentication with a BookmarkBeamAuth - Two-Factor Web Authentication with a Bookmark
BeamAuth - Two-Factor Web Authentication with a BookmarkBen Adida
 
Ettc Workshop Using A Prs System
Ettc Workshop   Using A Prs SystemEttc Workshop   Using A Prs System
Ettc Workshop Using A Prs Systemheinricb
 
Global connections in the classroom
Global connections in the classroomGlobal connections in the classroom
Global connections in the classroomheinricb
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?Karmen Blake
 
Open-Audit Voting
Open-Audit VotingOpen-Audit Voting
Open-Audit VotingBen Adida
 

Viewers also liked (7)

NJEA Podcasting Workshop
NJEA Podcasting WorkshopNJEA Podcasting Workshop
NJEA Podcasting Workshop
 
Secure Voting
Secure VotingSecure Voting
Secure Voting
 
BeamAuth - Two-Factor Web Authentication with a Bookmark
BeamAuth - Two-Factor Web Authentication with a BookmarkBeamAuth - Two-Factor Web Authentication with a Bookmark
BeamAuth - Two-Factor Web Authentication with a Bookmark
 
Ettc Workshop Using A Prs System
Ettc Workshop   Using A Prs SystemEttc Workshop   Using A Prs System
Ettc Workshop Using A Prs System
 
Global connections in the classroom
Global connections in the classroomGlobal connections in the classroom
Global connections in the classroom
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?
 
Open-Audit Voting
Open-Audit VotingOpen-Audit Voting
Open-Audit Voting
 

Similar to Get Going With RVM and Rails 3

What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...Matt Gauger
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortegaarman o
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction Tran Hung
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3Blazing Cloud
 
How To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuHow To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuVEXXHOST Private Cloud
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginnerUmair Amjad
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011Fabio Akita
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do railsDNAD
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & CucumberUdaya Kiran
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on railspmashchak
 

Similar to Get Going With RVM and Rails 3 (20)

Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction
 
Dev streams2
Dev streams2Dev streams2
Dev streams2
 
rails.html
rails.htmlrails.html
rails.html
 
rails.html
rails.htmlrails.html
rails.html
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
 
Rail3 intro 29th_sep_surendran
Rail3 intro 29th_sep_surendranRail3 intro 29th_sep_surendran
Rail3 intro 29th_sep_surendran
 
TorqueBox
TorqueBoxTorqueBox
TorqueBox
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
How To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on UbuntuHow To Install Ruby on Rails on Ubuntu
How To Install Ruby on Rails on Ubuntu
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
 
Intro to Rack
Intro to RackIntro to Rack
Intro to Rack
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
 

Recently uploaded

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Get Going With RVM and Rails 3

  • 1. Get started with Rails 3 by Karmen Blake Rails 3: Overview RVM: Ruby Version Manager Basic Rails 3 App
  • 3. Rails 3: Overview Merb Fast Lightweight Powerful = featureful, flexible, and extensible Rails Popular Easy to get started Opinionated Large ecosystem: books, blogs, screencasts, community
  • 5. Ruby Version Manager (RVM) Why? For me, I've been attached to Ruby 1.8.6 for a long time. Mostly because it is stable and legacy projects I work on rely on it. Lots of gems installed that just work. Rails 3 requires 1.8.7 and above! Doh!!!
  • 6. Ruby Version Manager (RVM) Command line tool which allows us to easily install, manage and work with multiple ruby environments (and associated gems).
  • 8. Ruby Version Manager (RVM) Installation: > mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install That is a long command, eh. You might want to go here and read for yourself: http://rvm. beginrescueend.com/rvm/install/ Follow instructions after that which involves adding a line to your bash profile.
  • 9. Installing Rails Using RVM > rvm install 1.9.1 (or 1.8.7 or 1.9.2) > rvm 1.9.1 --default (uses 1.9.1 on newly opened terminal windows) > curl -L http://rvm.beginrescueend.com/gemsets/rails3.gems -o rails3.gems > rvm gemset import rails3.gems > rails -v (should show Rails 3 beta) You may have to install sqlite/mysql and associated gems. For example, > gem install sqlite3-ruby
  • 10. Ruby Version Manager (RVM) A few more things: To use system ruby installed by default: > rvm system --default See installed rubies: > rvm list Named Gem Sets RVM not only isolates different ruby installations it also lets you isolate different gem sets. Thus you can mix and match rubies and gem sets. Amazing!! More here: http://rvm. beginrescueend.com/gemsets/basics/
  • 11. Introduction to Rails 3 Generate a Rails 3 app > rails generate app_name > rails g app_name script/rails is the only thing in there! Generate scaffold > rails g scaffold Post title:string body:text > rake db:migrate Start server > rails server > rails s
  • 12. Introduction to Rails 3 Console > rails console > rails c Database Console > rails dbconsole > rails db
  • 13. Introduction to Rails 3 ActiveRecord Validation Rails 2 - separate validations validates_presence_of :title validates_uniqueness_of :title validates_length_of :title, :maximum => 35 Rails 3 - puts validations together for a field validates :title, :presence => true, :uniqueness => true, :length => {:maximum => 35}
  • 14. Introduction to Rails 3 ActiveRecord Query Interface New API where(:conditions) having(:conditions) select group order limit includes(:include) and more...
  • 15. Introduction to Rails 3 ActiveRecord Query Interface Why New API? Chainability!!!! No not gold chains. :) Post.where(:title => "test") Post.where(:title => "test").order("created_at DESC") Post.order("created_at").limit(10) Post.where("created_at <= ?", Time.now).includes(:comments)
  • 16. Introduction to Rails 3 ActiveRecord Query Interface Lazy Loading posts = Post.all Returns a ActiveRelation object containing information about query. As soon as you access ActiveRelation object, for example in view, then call gets executed to db. Nice for fragment caching, etc. <% posts.each do |post| %> <li><%= post.title %></li> <% end %>
  • 17. Introduction to Rails 3 More Rails 3 Goodies: Router Mailer Unobtrusive Javascript ... Will have to wait for another presentation. :)
  • 18. Introduction to Rails 3 All you want to know and more about Rails 3 http://mediumexposure.com/rails-3-reading-material/ http://www.rubyinside.com/rails-3-0-beta-links-2966.html http://railslove.com/weblog/2010/02/02/on-the-way-to-rails- 3-a-link-list/ http://railsnotes.com/rails-3/
  • 19. References http://www.slideshare.net/GreggPollack/rails-3-beautiful- code-3219240 http://guides.rails.info/getting_started.html http://railscasts.com/episodes/202-active-record-queries-in- rails-3 http://m.onkey.org/2010/1/22/active-record-query-interface http://rvm.beginrescueend.com/ pik rvm tool on windows, I've never used though http://github.com/vertiginous/pik