This document provides an overview of Ruby on Rails in French. It discusses key aspects of Rails like MVC architecture, conventions over configuration, ActiveRecord, routing, asset pipeline, testing, generators, deployment with Capistrano, and popular gems. Popular Rails resources like guides and tutorials are also mentioned.
30. class Product < ActiveRecord::Base
end
ActiveRecord / migrations
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string :name
t.text :description
t.timestamps
end
end
end
db/migrate/20130626120509_create_products.rb
app/models/product.rb
31. ActiveRecord / migrations
mysql> show tables;
+---------------------------------+
| Tables_in_monapppli_development |
+---------------------------------+
| products |
| schema_migrations |
+---------------------------------+
2 rows in set (0.00 sec)
mysql> describe schema_migrations;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| version | varchar(255) | NO | PRI | NULL | |
+---------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> select * from schema_migrations;
+----------------+
| version |
+----------------+
| 20130626120509 |
+----------------+
1 row in set (0.00 sec)
35. class Product
validates_presence_of :name
end
ActiveRecord / validations
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string :name
t.text :description
t.timestamps
end
end
end
db/migrate/20130626120509_create_products.rb
app/models/product.rb