Rails Chops: Working with databases
References
- Read from: “The Rails Way” – Chapter 6
- Active Record Presentation
- Migrations Presentation (ignore mysql at beginning)
Objectives
- Configure Rails to work with a database (database.yml)
- create table (migration)
- use ActiveRecord to interact with our database
- use script/console to learn how ActiveRecord works
Model
- handle application state (usually in the database)
- encapsulate business logic, such as data validation and rules applied to data
ActiveRecord
- ORM (object-relational mapping)
- Instead of dealing with database through SQL statements, ORM layer presents records as a collection of objects
- Table represents a collection of objects(stories)
- Record represents an object/model (story)
- Field represents an object attribute (title)
CRUD operations on database
- C: create, insert record into table
- R: read, select record(s) from table
- U: update, update record(s) in the table
- D: delete, delete record(s) from the table
Images:


Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago