SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Ruby On Rails
 BeijingLUG



by Nathaniel Brown
    April 2007
Overview
●
    Install Ruby
●
    Install Rails
●
    (Optional) Install Eclipse
●
    Talk about Ruby
●
    Talk about Rails
●
    Example Application
●
    Links to Resources
Install Ruby
●
    sudo apt-get install ruby irb ri rdoc
●
    If you want to install mongrel you will also have
    to install the dev packages.
●
    sudo apt-get install ruby1.8-dev build-essential
Install Ruby Gems
●
    wget : http://rubyforge.org/frs/download.php/17190/
●
    tar xzvf rubygems-0.9.2.tgz
●
    cd rubygems-0.9.2
●
    sudo ruby setup.rb
●
    cd ..
●
    rm -rf rubygems-0.9.2
Install Rails and Mongrel
●
    sudo gem install rails --include-dependencies
●
    (Optional) sudo gem install mongrel --include-
    dependencies
●
    (Optional) Select the latest version of each
    library.
Install MySQL Server
●
    You could use PostgreSQL or SQLite instead
    but most examples use MySQL so we will as
    well.
●
    sudo apt-get install mysql-server phpmyadmin
    libmysql-ruby apache2 libapache2-mod-php5
(Optional) Install Eclipse
●
    sudo apt-get install eclipse sun-java5-jdk sun-
    java5-fonts
(Optional) Install RDT, RadRails and
       Aptana and Subclipse
●
    Open Eclipse and go to Help ->Software Updates
    -> Find and Install...
●
    Select “Search for new features to install” then
    click on “Next”.
●
    Add the following remote sites:
    RDT : http://updatesite.rubypeople.org/release
    RadRails : http://radrails.sourceforge.net/update
    Aptana : http://update.aptana.com/install/
    Subclipse : http://subclipse.tigris.org/update_1.2.x
●
    Once they have been added install all of them.
(Optional) Config RDT and RadRails
●
    Open Eclipse and go to Windows ->
    Preferences
●
    Find Ruby and add the Ruby interpreter.
●
    Find Rails and add the applications. They
    should all be in /usr/bin/*app name*
Ruby is a nice language
●
    Object Orientated
●
    Automatic garbage collection
●
    Sane readable code that makes sense.
Ruby example code 1
●
    Is readable

    puts "leon".reverse.capitalize

    staff_list = ["joe", "steve", "bob"]
    staff_list.sort!
    staff_list.each do |first_name|
     puts first_name.capitalize
    end

    3.times do |zork| puts "#{zork} " end
Ruby example code 2
−Tells       you if it will change the variable.
my_string = "12345"
new_string = my_string.chop
puts "String chopped."
puts "my_string: #{my_string}"
puts "new_string: #{new_string}"

my_string = "98765"
puts "my_string: #{my_string}"
my_string.chop!
puts "String chopped."
puts "my_string: #{my_string}"

my_number = 999474
puts my_number.to_s.include?("94")

my_string = "This is a test."
puts "#{my_string[3..5]}"
puts "#{my_string[2]}"
my_string[10..13] = "Ruby"
puts my_string
Ruby example code 3

−Lots      of things are just done really nicely.
#create our thread array
threads = []

5.times do |i|
  #create 5 threads into the array        
  threads[i] = Thread.new do
    #wait a random amount of time, then print a message
    sleep(rand(10))
    puts "I am thread number #{i}"
  end
end

#let each thread finish before ending the program
threads.each {|t| t.join}
Rails is a nice Framework
●
    Rapid Application Development
●
    Caching
●
    Model View Controller
●
    Nice informative errors

●
    DRY – Don't Repeat Yourself.
●
    Convention over Configuration
Rails supports modern features
●
    AJAX is build into the framework but JavaScript
    isn't required.
●
    Pretty URLs
●
    Active Record which is a type of Object
    Relation Mapping (ORM)
Rails encourages good
           development practices
●
    Validation
●
    Unit testing
●
    Use of development, testing and production
    environments with sane settings for each of
    them. e.g. Development has caching turned off.
    Production and Testing have it turned on.
●
    Version control is encouraged and assumed.
The Bad
●
    No manual only books.
●
    Ruby is relatively slow. (See Language Shoot-
    out)
●
    Rails is database driven which means it scales
    with the database.
●
    You'll often have to do things the “Rails Way”.
    (But it's often the right way as well)
●
    Lots of the 3rd party libraries are still unstable.
    (Improving quickly)
Create Your First Rails Applications
●
    If you are reading this online then go to the links
    section find RadRail's home page. He has a
    fairly good tutorial using RadRails.
Resources Links
●
    Rails for Fedora -
    http://digitalmediaminute.com/howto/fc4rails/
●
    RDT - http://rubyeclipse.sourceforge.net/
●
    RadRails and Aptana - http://www.radrails.org/
●
    Language Shoot-out -
    http://shootout.alioth.debian.org/
Cheat Sheets Links
●
    Rails, CSS, Javascript, HTML, etc (A4) -
    http://www.ilovejackdaniels.com/
●
    Nice Rails summary -
    http://www.blainekendall.com/index.php/rubyonrails
●
    A couple of Rails Cheat Sheets -
    http://www.slash7.com/goodies
Rails Links
●
    Ruby - http://www.ruby-lang.org/en/
●
    Ruby on Rails - http://www.rubyonrails.org/
●
    Ruby Forge - http://rubyforge.org/
●
    Free Ruby manual - http://www.poignantguide.net/ruby/
●
    Rails and Caching -
    http://www.railsenvy.com/2007/2/28/rails-caching-tutorial
●
    Ruby On Rails to exe -
    http://www.erikveen.dds.nl/distributingrubyapplications/rails.html
●
    Rails Tricks -
    http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-kno
●
    Rails Deployment -
    http://manuals.rubyonrails.com/read/book/17

Contenu connexe

Tendances

Fighting Ruby code smell
Fighting Ruby code smellFighting Ruby code smell
Fighting Ruby code smell
olegshpynov
 
Zap api and scripting - @iprav33nk
Zap api and scripting - @iprav33nkZap api and scripting - @iprav33nk
Zap api and scripting - @iprav33nk
Praveen Kumar
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applications
railsconf
 

Tendances (19)

What's new in RubyGems3
What's new in RubyGems3What's new in RubyGems3
What's new in RubyGems3
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
 
Introduction to rails
Introduction to railsIntroduction to rails
Introduction to rails
 
The Future of library dependency management of Ruby
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of Ruby
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
 
RubyMotion #jbday
RubyMotion #jbdayRubyMotion #jbday
RubyMotion #jbday
 
Rango
RangoRango
Rango
 
rsyslog meets docker
rsyslog meets dockerrsyslog meets docker
rsyslog meets docker
 
Ruby Security the Hard Way
Ruby Security the Hard WayRuby Security the Hard Way
Ruby Security the Hard Way
 
Fighting Ruby code smell
Fighting Ruby code smellFighting Ruby code smell
Fighting Ruby code smell
 
WTF Is Rancher?
WTF Is Rancher?WTF Is Rancher?
WTF Is Rancher?
 
遇見 Ruby on Rails
遇見 Ruby on Rails遇見 Ruby on Rails
遇見 Ruby on Rails
 
Zap api and scripting - @iprav33nk
Zap api and scripting - @iprav33nkZap api and scripting - @iprav33nk
Zap api and scripting - @iprav33nk
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparison
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applications
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About Rails
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 

En vedette (8)

Accessing_MySQL_from_Ruby
Accessing_MySQL_from_RubyAccessing_MySQL_from_Ruby
Accessing_MySQL_from_Ruby
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorial
 
lab56_db
lab56_dblab56_db
lab56_db
 
ruby-efl-tutorial-hsyl20
ruby-efl-tutorial-hsyl20ruby-efl-tutorial-hsyl20
ruby-efl-tutorial-hsyl20
 
rails.html
rails.htmlrails.html
rails.html
 
has_many_and_belongs_to_many
has_many_and_belongs_to_manyhas_many_and_belongs_to_many
has_many_and_belongs_to_many
 
wtst3_pettichord3
wtst3_pettichord3wtst3_pettichord3
wtst3_pettichord3
 
Difference between flyers, brochures, posters & leaflets
Difference between flyers, brochures, posters & leafletsDifference between flyers, brochures, posters & leaflets
Difference between flyers, brochures, posters & leaflets
 

Similaire à rubyonrails

Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo
 

Similaire à rubyonrails (20)

RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
 
SELF - Becoming a Rails Developer - The Rest of the Story
SELF - Becoming a Rails Developer - The Rest of the StorySELF - Becoming a Rails Developer - The Rest of the Story
SELF - Becoming a Rails Developer - The Rest of the Story
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Montreal.rb ruby debugging basics - march 20th 2012
Montreal.rb   ruby debugging basics - march 20th 2012Montreal.rb   ruby debugging basics - march 20th 2012
Montreal.rb ruby debugging basics - march 20th 2012
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Puppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven Development
 
20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
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
 
Ruby confhighlights
Ruby confhighlightsRuby confhighlights
Ruby confhighlights
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Autolab Workshop
Autolab WorkshopAutolab Workshop
Autolab Workshop
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 

Plus de tutorialsruby

<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
tutorialsruby
 
TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>
tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
tutorialsruby
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
tutorialsruby
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 

Plus de tutorialsruby (20)

<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>TopStyle Help & <b>Tutorial</b>
TopStyle Help & <b>Tutorial</b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

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
 
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
 
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
 
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
 
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?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
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...
 

rubyonrails

  • 1. Ruby On Rails BeijingLUG by Nathaniel Brown April 2007
  • 2. Overview ● Install Ruby ● Install Rails ● (Optional) Install Eclipse ● Talk about Ruby ● Talk about Rails ● Example Application ● Links to Resources
  • 3. Install Ruby ● sudo apt-get install ruby irb ri rdoc ● If you want to install mongrel you will also have to install the dev packages. ● sudo apt-get install ruby1.8-dev build-essential
  • 4. Install Ruby Gems ● wget : http://rubyforge.org/frs/download.php/17190/ ● tar xzvf rubygems-0.9.2.tgz ● cd rubygems-0.9.2 ● sudo ruby setup.rb ● cd .. ● rm -rf rubygems-0.9.2
  • 5. Install Rails and Mongrel ● sudo gem install rails --include-dependencies ● (Optional) sudo gem install mongrel --include- dependencies ● (Optional) Select the latest version of each library.
  • 6. Install MySQL Server ● You could use PostgreSQL or SQLite instead but most examples use MySQL so we will as well. ● sudo apt-get install mysql-server phpmyadmin libmysql-ruby apache2 libapache2-mod-php5
  • 7. (Optional) Install Eclipse ● sudo apt-get install eclipse sun-java5-jdk sun- java5-fonts
  • 8. (Optional) Install RDT, RadRails and Aptana and Subclipse ● Open Eclipse and go to Help ->Software Updates -> Find and Install... ● Select “Search for new features to install” then click on “Next”. ● Add the following remote sites: RDT : http://updatesite.rubypeople.org/release RadRails : http://radrails.sourceforge.net/update Aptana : http://update.aptana.com/install/ Subclipse : http://subclipse.tigris.org/update_1.2.x ● Once they have been added install all of them.
  • 9. (Optional) Config RDT and RadRails ● Open Eclipse and go to Windows -> Preferences ● Find Ruby and add the Ruby interpreter. ● Find Rails and add the applications. They should all be in /usr/bin/*app name*
  • 10. Ruby is a nice language ● Object Orientated ● Automatic garbage collection ● Sane readable code that makes sense.
  • 11. Ruby example code 1 ● Is readable puts "leon".reverse.capitalize staff_list = ["joe", "steve", "bob"] staff_list.sort! staff_list.each do |first_name| puts first_name.capitalize end 3.times do |zork| puts "#{zork} " end
  • 12. Ruby example code 2 −Tells you if it will change the variable. my_string = "12345" new_string = my_string.chop puts "String chopped." puts "my_string: #{my_string}" puts "new_string: #{new_string}" my_string = "98765" puts "my_string: #{my_string}" my_string.chop! puts "String chopped." puts "my_string: #{my_string}" my_number = 999474 puts my_number.to_s.include?("94") my_string = "This is a test." puts "#{my_string[3..5]}" puts "#{my_string[2]}" my_string[10..13] = "Ruby" puts my_string
  • 13. Ruby example code 3 −Lots of things are just done really nicely. #create our thread array threads = [] 5.times do |i|   #create 5 threads into the array           threads[i] = Thread.new do     #wait a random amount of time, then print a message     sleep(rand(10))     puts "I am thread number #{i}"   end end #let each thread finish before ending the program threads.each {|t| t.join}
  • 14. Rails is a nice Framework ● Rapid Application Development ● Caching ● Model View Controller ● Nice informative errors ● DRY – Don't Repeat Yourself. ● Convention over Configuration
  • 15. Rails supports modern features ● AJAX is build into the framework but JavaScript isn't required. ● Pretty URLs ● Active Record which is a type of Object Relation Mapping (ORM)
  • 16. Rails encourages good development practices ● Validation ● Unit testing ● Use of development, testing and production environments with sane settings for each of them. e.g. Development has caching turned off. Production and Testing have it turned on. ● Version control is encouraged and assumed.
  • 17. The Bad ● No manual only books. ● Ruby is relatively slow. (See Language Shoot- out) ● Rails is database driven which means it scales with the database. ● You'll often have to do things the “Rails Way”. (But it's often the right way as well) ● Lots of the 3rd party libraries are still unstable. (Improving quickly)
  • 18. Create Your First Rails Applications ● If you are reading this online then go to the links section find RadRail's home page. He has a fairly good tutorial using RadRails.
  • 19. Resources Links ● Rails for Fedora - http://digitalmediaminute.com/howto/fc4rails/ ● RDT - http://rubyeclipse.sourceforge.net/ ● RadRails and Aptana - http://www.radrails.org/ ● Language Shoot-out - http://shootout.alioth.debian.org/
  • 20. Cheat Sheets Links ● Rails, CSS, Javascript, HTML, etc (A4) - http://www.ilovejackdaniels.com/ ● Nice Rails summary - http://www.blainekendall.com/index.php/rubyonrails ● A couple of Rails Cheat Sheets - http://www.slash7.com/goodies
  • 21. Rails Links ● Ruby - http://www.ruby-lang.org/en/ ● Ruby on Rails - http://www.rubyonrails.org/ ● Ruby Forge - http://rubyforge.org/ ● Free Ruby manual - http://www.poignantguide.net/ruby/ ● Rails and Caching - http://www.railsenvy.com/2007/2/28/rails-caching-tutorial ● Ruby On Rails to exe - http://www.erikveen.dds.nl/distributingrubyapplications/rails.html ● Rails Tricks - http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-kno ● Rails Deployment - http://manuals.rubyonrails.com/read/book/17