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

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
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...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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