Please view in full screen:
Wednesday, April 23, 2008
Monday, April 21, 2008
Rails Chops: Editing data
Concepts:
- ActiveRecord - update attributes
- RESTful routing - edit/update
- partials
Please view in full screen.
Monday, April 14, 2008
Rails Chops: Creating new stories and validations
Concepts:
- New/Create RESTful routes
- Form Helpers
- Validations
FYI, video looks much better in full-screen.
Friday, April 11, 2008
Rails Chops: Starting a Rails App
Concepts:
- ActiveRecord Basics
- Migration Basics
- Creating a controller and a view
Wednesday, April 9, 2008
Rails Chops: RESTful Routes
Reference: Chapter 4 (The Rails Way)
In Rails, by adding
Slowly but surely we are going to build an app from the ground up and use all of these RESTful routes. Its very important to understand what each of these do and how to incorporate them into your application. These routes control how we setup our controller, actions, links, and forms. It is amazing how much is conventionalized around one configuration line
In Rails, by adding
map.resources :stories to config/routes.rb, you get 7 predefined routes:- stories GET /stories {:controller=>”stories”, :action=>”index”}
- POST /stories {:controller=>”stories”, :action=>”create”}
- new_story GET /stories/new {:controller=>”stories”, :action=>”new”}
- edit_story GET /stories/:id/edit {:controller=>”stories”, :action=>”edit”}
- story GET /stories/:id {:controller=>”stories”, :action=>”show”}
- PUT /stories/:id {:controller=>”stories”, :action=>”update”}
- DELETE /stories/:id {:controller=>”stories”, :action=>”destroy”}
Slowly but surely we are going to build an app from the ground up and use all of these RESTful routes. Its very important to understand what each of these do and how to incorporate them into your application. These routes control how we setup our controller, actions, links, and forms. It is amazing how much is conventionalized around one configuration line
map.resources :stories- POST is a CREATE
- GET is a READ
- PUT is an UPDATE
- DELETE is a DELETE
Sunday, April 6, 2008
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
Subscribe to:
Posts (Atom)