Ruby on Rails for beginners


Published on

Introduction to Ruby and Introduction to Ruby on Rails basic concepts for beginners. The google presentation is even better in full screen

Published in: Software, Technology
  • Ruby (Oprah's Book Club 2.0) ---
    Are you sure you want to  Yes  No
    Your message goes here
  • Sterling Silver Created Ruby and Created White Sapphire Wrapped Heart Pendant Necklace, 18" ---
    Are you sure you want to  Yes  No
    Your message goes here
  • The Ruby Programming Language ---
    Are you sure you want to  Yes  No
    Your message goes here
  • lol
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ruby on Rails for beginners

  1. I am Vysakh. I am a web developer.
  2. In Ruby puts “Hello world”
  3. Ruby is simply simple Just like english
  4. Variables
  5. You have - basket A with 10 apples - basket B with 20 apples. Find the sum and difference
  6. basketa = 10 apples basketb = 20 apples sum = basketa + basketb => 10 + 20 = 30 difference = basketb - basketa => 20 - 10 = 10
  7. basket_a = 10 basket_b = 20 sum = basket_a + basket_b difference = basket_b - basket_a In Ruby
  8. It is just like what you wrote in your kindergarden answer sheet
  9. Creator of Ruby - Matz
  10. Running the code
  11. Ruby is executed line by line So output of a single line/logic can be seen using irb
  12. Opening up irb in the terminal Instead of executing as a program file. Useful for learning, debugging.
  13. Conditionals
  14. cold_weather = true if cold_weather puts “Wear something warm” else puts “Don’t wear something” end Ruby code
  15. Most thing in Ruby is Object
  16. 2.odd?() => false “Vysakh”.length() => 6
  17. Brackets are optional in Ruby 2.odd? => false “Vysakh”.length => 6
  18. Exercise 1 a) Get a string and check if it is palindrome. b) Get a number and print the reverse of it. Hint: use gets to get the input.
  19. Array/List
  20. In Ruby shopping = [ “milk”, “cheese”, “olive oil”]
  21. Loops
  22. In Ruby 20.times do puts “I must do my homework” end
  23. Also, there are - loop - while loop - for loop - step - upto
  24. HAPPY Ruby is all about making programmer
  25. Mam, please take each item for me to bill
  26. cart = [“biscuit”, milk”, “shampoo”, “tampons” ]
  27. Mam, please take each item for me to bill cart = [“biscuit”, milk”, “shampoo”, “tampons” ] cart.each do |item| puts item end
  28. Exercise 2 - Create an array of marks you got in your last assessment. - Find if the sum of odd numbers is greater than the sum of even numbers, if it is, you have big odds at passing. - Pass this information or bad luck will follow
  29. HASH
  30. In Ruby slang = { “lol” => “laugh out loud”, “brb” => “Be right back” } slang[“lol”] => laught out loud
  31. Use symbols instead of string slang = { :lol => “laugh out loud”, :brb => “Be right back” } slang[:lol] => laught out loud
  32. Symbols in Ruby :hand.class => Symbol
  33. Alternate way to write hash slang = { lol: “laugh out loud”, brb: “Be right back” } slang[:lol] => laught out loud
  34. Exercise 3 - Create a list of ipl team hashes - with batsmen (3) name as key and their sixes as values. a) Find the sixes hit by a batsmen of a given name
  35. Functions
  36. In Ruby def y(x) x**3 end y(3) # => 27 y(2) # => 8
  37. Exercise 4 a) Create a method rajini_style. Return his dialogue (your favorite). b) Create a factorial method that gets a number and returns the factorial
  38. Class
  39. class Sports def initialize(players, name) @no_of_players = players @name = name end end cricket =, “Cricket”) foot_ball =, “Football”)
  40. Inheritance
  41. a version manager (RVM or rbenv or other) Install ruby using
  42. rbenv Installing Ruby using
  43. Installing and setting Ruby
  44. dhh Creator of Ruby on Rails
  45. Installing Rails
  46. Creating a new rails project
  47. Files generated with “rails new myproject” command
  48. Starting Rails server
  49. Check the browser localhost:3000
  50. Understanding Rails
  51. A dress shop Pant section? 1st floor kid. 2nd section
  52. 1st floor here is your pant
  53. A Rails server /about routes.rb home controller, about action
  54. A Rails server home controller, about action here is your html file
  55. Lets do it in Rails
  56. filename: config/routes.rb Configure the routes to get /about
  57. The corresponding html
  58. and go to ‘/about’ url Lets open the browser
  59. available in the section? When the pant is not Coming back to the kid and pant story
  60. 1st floor I want this specific design Godown Oh kid lemme go to the godown and get
  61. In Rails Database home controller, about action /posts/1
  62. and have an abstraction(model) Lets create a table
  63. This will create model, migration files
  64. migration - A ruby file that will create, modify tables posts table title column of type string
  65. from the ruby file(migration) Lets create the tables
  66. Rake, a simple ruby build program with capabilities similar to make This creates the posts table
  67. table records through Rails model Lets create, manipulate
  68. Post is a Ruby class that Inherits ActiveRecord app/models/post.rb
  69. Object Relation Mapping(ORM) layer Active Record is an
  70. tables map to classes,
  71. rows map to objects rows map to objects Rows map to objects Columns map to object attributes
  72. Few operations
  73. Lets use this query in Rails controller and give it to the user
  74. Configure the routes file
  75. Open up the browser
  76. Show the title, description in html app/views/show.html.erb
  77. Now lets check the browser
  78. Now lets do all this in one command -> scaffold
  79. This will generate all files based on REST Architecture
  80. Guides and resources
  81. Ruby
  82. Ruby on Rails
  83. Local Ruby Community - chennair.b Mailing list - google groups Meetups -