Building something with rails

Ruby is a powerful, flexible programming language you can use in web/Internet development, to process text, to create games, and as part of the popular Ruby on Rails web framework.

RUBY IS:

High-level: meaning reading and writing Ruby is really easy—it looks a lot like regular English.

5.times { print "Im learning rails!" }

Interpreted: meaning you don't need a compiler to write and run Ruby.

Object-oriented: meaning it allows users to manipulate data structures called objects in order to build and execute programs. All you need to know is that (almost) everything in Ruby is an object.

Easy to use: Ruby was designed by Yukihiro Matsumoto in 1995. Matz set out to design a language that emphasized human needs over those of the computer.

RAILS IS:

Rails is a web application development framework written in the Ruby language. It allows you to write less code while accomplishing more than many other languages and frameworks. 

 

Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's designed to encourage that way - and in some cases to discourage alternatives.

Don't Repeat Yourself

Convention Over Configuration

The Rails philosophy includes two major guiding principles:

MVC

$ ruby -v

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

$ rails -v

Rails 5.0.0.1

$ sqlite3 --version

3.8.10.2 2015-05-20 18:17:19 2ef4f3a5b1d1d0c4338f8243d40a2452cc1f7fe4

GETTING DIRTY

$ rails new pokedex

      create
      create  README.md
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/javascripts/application.js
      create  app/assets/javascripts/cable.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
$ rails server

=> Booting Puma
=> Rails 5.0.0.1 application starting in development 
   on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

localhost:3000

The end

$ rails generate controller welcome index

Running via Spring preloader in process 81057
      create  app/controllers/welcome_controller.rb
       route  get 'welcome/index'
      invoke  erb
      create    app/views/welcome
      create    app/views/welcome/index.html.erb
      invoke  test_unit
      create    test/controllers/welcome_controller_test.rb
      invoke  helper
      create    app/helpers/welcome_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/welcome.coffee
      invoke    scss
      create      app/assets/stylesheets/welcome.scss

http://localhost:3000/welcome/index

RUBYGEMS

RubyGems is a package manager for the Ruby that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.

gem 'slim'
gem 'pry-rails'
gem 'bootstrap-sass'
gem 'simple_form'
$ rails generate model pokemon

POKEMON MODEL

Text

   nat
   name
   hp
   atk
   def
   spA
   spD
   typeI
   typeII
   abilityI
   abilityII
   hiddenAbility
   mass
   color

POKEMON Controller

$ rails generate controller pokemons index
GET This is used to provide a read only access to a resource.
POST This is used to update a existing resource or create a new resource.
DELETE This is used to remove a resource.
PUT This is used to create a new resource.

http methods:

$ rails routes

POKEMON VIEW

Designing the rest of the application....

ccontreras@nearsoft.com

https://github.com/DarthCharles

Thanks!

Building Something with Rails 5

By Carlos Contreiras

Building Something with Rails 5

:D

  • 436