rubyonrails 120409061835-phpapp02
TRANSCRIPT
![Page 1: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/1.jpg)
RUBY ON RAILS
![Page 2: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/2.jpg)
AN INTRODUCTION…
Some general things:
o Ruby is the programming language.
o Rails is a Web Development Framework on top of Ruby.
![Page 3: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/3.jpg)
ABOUT RUBY
Ruby is:
o Dynamic – executes on runtime.
o Reflective – modifies itself on runtime.
o General purpose – can be used for any programming purpose.
oOpen Source…
o Object oriented…
o High-Level…
![Page 4: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/4.jpg)
THE RUBY STORY
Developed in the early-1990s.
Created by Yukihiro "Matz" Matsumoto.
Originates from Japan.
First released on February 1995.
Next major release, Ruby 2.0 expected on 2013.
![Page 5: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/5.jpg)
TECHNICAL INFO
Interprets to C.
Uses the best practices from Perl, Smalltalk, Eiffel, and Lisp.
Ruby follows the principle of least astonishment (POLA). Works as expected.
Alternative implementations of Ruby, including YARV, JRuby, Rubinius, IronRuby,MacRuby, and HotRuby.
![Page 6: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/6.jpg)
INSTALLING RUBY
Depending on tour system there are many different installation ways.
The 3 basic Ways are:1. You can compile it from source.2. You can install it through 3rd party
tools, RVM – Linux/MacOS, Ruby Installer – Windows.
3. Via package managers:Apt-get install, yum install,brew install, pacman –S etc.
![Page 7: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/7.jpg)
FILE EXTENSIONS
The most popular file extensions of Ruby (and also Rails) files are:
o .rb the Ruby class files.
o .gem Ruby package files that may containRuby programs and libraries.
o .yml data mapping files.
o .html.erb Ruby html files.
![Page 8: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/8.jpg)
DO YOU SPEAK RUBY?
Ruby is a scripting language, which has one goal:
To be programmer friendly.
So it's expressive, and closer to physical language.
![Page 9: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/9.jpg)
SOME RUBY TALK
Something no one ever seen before…Let’s do an innovative Hello World example:
puts "Hello World!"
![Page 10: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/10.jpg)
RUBY LOGIC
In Ruby Everything is an object. There are no primitive types. Lines and | are code seperators.
No need to declare variable types. For exampe:
@name #a variable@name = 2 #a number@name = “Kaiser Chiefs” #a String@name = 1..52 #a range@name = [“Rails”,12,[6,7,9],3..53]
#a collection
![Page 11: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/11.jpg)
RUBY LOGIC AGAIN
A class exampleclass Person
attr_accessor :nameend
Class instance Examplebob = Person.newbob.name = “Bob the Builder” Blocks example – blocks are anonymous functions workers = [Bob, Maria, George, Sylvia]for person in workers do
puts person.nameendworkers.each do |person|
puts person.nameend
![Page 12: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/12.jpg)
RUBY LOGIC AGAIN AND AGAIN
Iterrators examplebest_workers = workers.select{|person| person.name.include? ”a”} Hashes are a great way to store things:
Hash examplefav_djs = {“tiesto” => 8, “deadmau5” => 6, “kaskade” => 3, “benassi” => 7}fav_djs[“deadmau5”] >> 6fav_djs[“benassi”]+=2 >> 9fav_djs[“afrojack”] = 5
![Page 13: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/13.jpg)
HOW TO HACK SOMETHING USING RUBY…
Now we know enough to…
Just Kiddin, let’s dive into Rails
![Page 14: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/14.jpg)
Rails
![Page 15: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/15.jpg)
SO? WHAT’S RAILS?•Open source
• MVC Web Framework
•Optimized for programmer happiness.
•Developed for database backed web applications,.
•Very AGILE
![Page 16: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/16.jpg)
FOR STARTERS
Rails is a ruby web framework.
It was designed by David Heinemeier Hansson.
Was released as an open source project on 2004.
And joined Mac on 2007.
![Page 17: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/17.jpg)
MVC ON RAILS
![Page 18: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/18.jpg)
SOMETIMES PICTURES AREN’T ENOUGH
• This pattern splits the view (also called the presentation) into "dumb" templates that are primarily responsible for inserting pre-built data in between HTML tags. • The model contains the "smart" domain objects (such as Account, Product, Person, Post) that holds all the business logic and knows how to persist themselves to a database.
• The controller handles the incoming requests (such as Save New Account, Update Product, Show Post) by manipulating the model and directing data to the view.
![Page 19: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/19.jpg)
RAILS FIGHTS FOR
Write Less Do More.
DRY – Don’t Repeat Yourself.
COC – Convention over Configuration.
REST- Representational State Transfer.
![Page 20: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/20.jpg)
HOW EASY IS TO LEARN RAILS?
![Page 21: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/21.jpg)
RAILS CAPABILITIES
•ORM : Object Relational Mapping.
•CRUD: Create Read Update Deletea Database.
•Both BDD and TDD: Behavior and Test Driven Development.
•Ajax and Web Services.
•Meta Programming.
![Page 22: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/22.jpg)
WHAT IS ORM?
Active Record (ORM)An ORM layer built-in maps classes to tables so :
•Every row is an object.•Every column is an object attribute.
Also it uses conventions to minimize configuration.
![Page 23: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/23.jpg)
COMPATIBILITY
Most Platforms :Linux, Windows, MacOs etc.
Most Databases : MySQL, Sqlite, NoSQL etc.
A lot of Web Servers :Nginx, Apache, Passenger etc.
![Page 24: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/24.jpg)
RAILS VS JAVA AND PHP
![Page 25: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/25.jpg)
GETTING STARTED
All Rails Apps use the same structure.
No matter the editor or IDE you are using, the projects have the same build.
The newer versions always support the older.
![Page 26: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/26.jpg)
RAILS 3.0 PROJECT STRUCTURE
![Page 27: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/27.jpg)
DEVELOPER TOOLS
Editors: vim, gedit, Textmate and more
IDEs: RubyMine, Eclipse with plugin, Aptana, Radrails, 3rdRail
![Page 28: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/28.jpg)
GETTING STARTED
Installation, 3 steps:
1. Open your terminal, no matter the OS you are using.
2. Type: gem install rails
3. Press enter, sit back and enjoy.
![Page 29: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/29.jpg)
BUILD YOUR FIRST APP
1. Open your terminal and cd to the folder where you want to place your project .
2. Type & enter:rails new Project_Name
3. Type & enter:rails s
4. Visit your localhost:3000, from your browser
5. You can see your first rails app running
![Page 30: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/30.jpg)
BUILD YOUR FIRST APPThis is what you would
see…
![Page 31: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/31.jpg)
FAMOUS WEBSITES ON RAILS
![Page 32: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/32.jpg)
FAMOUS WEBSITES ON RAILS
![Page 33: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/33.jpg)
FAMOUS WEBSITES ON RAILS
![Page 34: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/34.jpg)
FAMOUS WEBSITES ON RAILS
![Page 35: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/35.jpg)
USEFUL LINKS
• http://rubyonrails.org/• http://railsforzombies.org/• http://ruby.railstutorial.org/• http://www.aptana.com/products/rad
rails• http://railscasts.com/• http://www.ruby-forum.com/forum/r
ails• http://www.google.gr/
![Page 36: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/36.jpg)
AND SOME PERSONAL TIPS
Don’t be afraid to search and try, it pays… a lot.
![Page 37: Rubyonrails 120409061835-phpapp02](https://reader033.vdocument.in/reader033/viewer/2022052823/555218f7b4c90520548b4b06/html5/thumbnails/37.jpg)
THANK YOU !!!
Don’t worry guys,Just gotta practice !!!!