rails course day 2

15
Ruby on rails course By @AlSayed Gamal

Upload: al-sayed-gamal

Post on 22-Jan-2017

229 views

Category:

Software


0 download

TRANSCRIPT

Ruby on rails course

By @AlSayed Gamal

Day 2: Anatomy of Rails application

AgendaInspecting Scaffolded Application.

routes

controllers

Migrations

Models

Views and Partials

Rails command line

RoutesThe art of triggering code based on HTTP request

routes

rake routes

routes.rb

root route

nested routes

RESTful routes

ControllersThin yet powerful

Controllers

In the center of MVC.

Delegates all the tasks.

handling different formats.

RESTful controllers

notices and redirections.

•instance variables and rendering.

Controllers (cont.)Your Controller < Application Controller

•layout binding •before_filter

MigrationsChanging DB 1 step a time

Migrations Tracking changes on schema nightmare.

Generate Migration by convention

To be able to rollback schema changes

rails g migration

Migration < ActiveRecord::Migration

Up,Down and change

rollingback

ModelsFat is good.

Models

Generation

Validations

ORM

Model methods

Model Static methods

Manipulation of models using (rails console).

STI

Views

Layouts

ERB syntax

views convention

partials

helpers

Rails Basic Command line

rails c, d, g and d

rake routes and db

What’s rake task ?

Thank you!