Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on Rails Introduction

Ruby on Rails Introduction

This is an introduction of Ruby and Ruby on Rails for Alicante Tech Meetup 2015/07/14

Yusuke Mito

July 15, 2015
Tweet

More Decks by Yusuke Mito

Other Decks in Technology

Transcript

  1. Cookpad http://info.mis-recetas.org/jobs/ Our mission Make everyday cooking fun We’re searching

    for No.1 engineer! Cookpad is A company which solves user’s issues by technology A company which solves issues of all the people in the world
  2. 1995 v0.95 History of Ruby 2003 v1.8 2007 v1.9 2013

    Feb. v2.0 2013 Dec. v2.1 2014 v2.2 Ruby is intensively developed over 20 years
  3. $ cat hello.rb class Hello def initialize(name) @name = name

    end def say puts "Hello, #{@name}!" end end hello = Hello.new("David") hello.say $ ruby hello.rb #=> Hello, David! class declaration→ method declaration→ Instantiation→ Method call→ Basic Ruby Syntax instance variable→
  4. rbenv # install ruby 2.1.5 $ rbenv install 2.1.5 $

    rbenv shell 2.1.5 $ ruby -v ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux] # install ruby 2.2.2 $ rbenv install 2.2.2 $ rbenv shell 2.2.2 $ ruby -v ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] Simple Ruby Version Management Tool There are similar tools for other languages: plenv phpenv pyenv…
  5. RubyGems is a standard package manager for the Ruby Anyone

    can make own gem and publish it to https://rubygems.org RubyGems # install gem $ gem install nokogiri $ irb > require ‘nokogiri’ > doc = Nokogiri::HTML.parse('<div class="hello">world</div>') > doc.search('.hello').text => "world" * irb is Interactive Ruby. REPL for Ruby. Similar to PEAR for PHP, CPAN for Perl, pip for Python, npm for Node.js etc
  6. Managing the gems that the application depends on Bundler $

    cat Gemfile source ‘https://rubygems.org' gem ‘nokogiri’ gem ‘rails’ $ bundle #=> Install all gems listed in Gemfile Bundler makes sure Ruby applications run the same code on every machine by installing given list of gems and its depending gems Similar to composer for PHP, carton for Perl, CocoaPods for iOS, etc
  7. Model - ActiveRecord - O/R Mapper View - ActionView -

    View Template Handler Controller - ActionPack - Request/Response Handler Most important frameworks
  8. ActiveSupport - Utilities and Ruby Extensions ActiveJob - Asynchronous Job

    Queue ActionMailer - Email Delivering And other useful frameworks
  9. Haml is a template language that provides more simple and

    clean syntax for markup Haml <section class=”container”> <h1><%= post.title %></h1> <h2><%= post.subtitle %></h2> <div class=”content”> <%= post.content %> </div> </section> %section.container %h1= post.title %h2= post.subtitle .content = post.content
  10. You can build a complex form with less code than

    default form builder Simple Form <%= form_for @user do |f| %> <div> <%= f.label :name %> <%= f.text_field :name %> </div> <div> <%= f.label :email %> <%= f.text_field :email %> </div> <div> <%= f.label :birthday %> <%= f.date_field :birthday %> </div> <div> <%= f.submit %> </div> <% end %> <%= simple_form_for @user do |f| %> <%= f.input :name %> <%= f.input :email %> <%= f.input :birthday %> <%= f.button :submit %> <% end %>
  11. carrierwave - Flexible Image Uploader kaminari - De facto paginator

    for Rails omniauth - Standardizes multi provider authentication redcarpet - Markdown parser and renderer Other useful gems
  12. Rails Guides - Official guide of rails http://guides.rubyonrails.org/ Rails Girls

    Guides - Rails guide for beginner programmer http://guides.railsgirls.com/ Rails Tutorial https://www.railstutorial.org/book Rails API References http://api.rubyonrails.org/ Good documents to learn Rails