Bienvenid@s al primer taller de Rails Básico

Conoce tu comunidad...

Organizadores

Mentores

@herzogbreton

@papayalabs

@melissaramire58

@jldiaz16

Patrocinadores

¿Qué es Rails?

http://rubyonrails.org.es/

Filosofía de Rails

1. Don't repeat yourself

2. Convention over configuration

Verifiquemos...

Versión de Ruby:

Versión de Rails:

# ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
# rails -v
Rails 5.1.1

# gem list |grep rails
rails (5.1.1)

1. Instala Ruby

http://rubyonrails.org.es/instala.html

2. Instala Rails 5!!!

# gem install rails

3. Crea tu primer proyecto en Rails

# rails new todo

¿Qué es una Gema?

bundle_path

Son "librerías"

Gemfile...

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.1.3'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Migraciones..

Creemos la BD..

#rails db:create

RubyDep: WARNING: Your Ruby is outdated/buggy.
RubyDep: WARNING: Your Ruby is: 2.3.0 (buggy). Recommendation: upgrade to 2.3.1.
RubyDep: WARNING: (To disable warnings, see:http://github.com/e2/ruby_dep/wiki/Disabling-warnings )
Created database 'db/development.sqlite3'
Created database 'db/test.sqlite3'
#rails g migration create_todos
RubyDep: WARNING: Your Ruby is outdated/buggy.
RubyDep: WARNING: Your Ruby is: 2.3.0 (buggy). Recommendation: upgrade to 2.3.1.
RubyDep: WARNING: (To disable warnings, see:http://github.com/e2/ruby_dep/wiki/Disabling-warnings )
RubyDep: WARNING: Your Ruby is outdated/buggy.
RubyDep: WARNING: Your Ruby is: 2.3.0 (buggy). Recommendation: upgrade to 2.3.1.
RubyDep: WARNING: (To disable warnings, see:http://github.com/e2/ruby_dep/wiki/Disabling-warnings )
Running via Spring preloader in process 18267
      invoke  active_record
      create    db/migrate/20170804021306_create_todos.rb

Agregando la tabla..

Lo que genera Rails

class CreateTodos < ActiveRecord::Migration[5.1]
  def change
    create_table :todos do |t|
    end
  end
end
class CreateTodos < ActiveRecord::Migration[5.1]
  def change
    create_table :todos do |t|
      t.string :description, null: false
      t.datetime :date, null: false
      t.string :status, null: false

      t.timestamps
    end
  end
end

db/schema..

Correr migraciones..

# rails db:migrate
== 20170804021306 CreateTodos: migrating ======================================
-- create_table(:todos)
   -> 0.0012s
== 20170804021306 CreateTodos: migrated (0.0022s) =============================
ActiveRecord::Schema.define(version: 20170804021306) do

  create_table "todos", force: :cascade do |t|
    t.string "description", null: false
    t.datetime "date", null: false
    t.string "status", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

end

Convertir el resto..

Convertir el app_layout a haml..

#rails generate haml:application_layout convert
#rake haml:erb2haml
#rake haml:erb2haml

Almuerzo...

https://github.com/Jinara/todo

¡¡Gracias!!

Made with Slides.com