The document discusses several Rails tools including Gemfiles for managing dependencies, database migrations for schema versioning, data seeding for loading data, generators for creating boilerplate code, the rails console and dbconsole for debugging, common rake tasks, and the asset pipeline for managing CSS, JS, and image assets.
4. Gemfile
Keeps track of all dependencies in your project
Specify alternate gem repositories (like a corporate gem repo)
Friday, May 10, 2013
5. Gemfile
Keeps track of all dependencies in your project
Specify alternate gem repositories (like a corporate gem repo)
Group dependencies by environment
Friday, May 10, 2013
6. Add a gem dependency
gem‘gem_name’
gem‘gem_name’,‘version’
gem‘gem_name’,‘git_repo’
Gemfile
Keeps track of all dependencies in your project
Specify alternate gem repositories (like a corporate gem repo)
Group dependencies by environment
Friday, May 10, 2013
7. Database Migrations in Depth
Keep your database structure in sync in all environments
Development (Bleeding Edge)
Testing (Close to development or slightly behind)
Production (Behind testing and development)
Friday, May 10, 2013
8. Database Migrations in Depth
Keep your database structure in sync in all environments
Development (Bleeding Edge)
Testing (Close to development or slightly behind)
Production (Behind testing and development)
schema_migrations table used to track versions
Friday, May 10, 2013
9. Database Migrations in Depth
Keep your database structure in sync in all environments
Development (Bleeding Edge)
Testing (Close to development or slightly behind)
Production (Behind testing and development)
Development
Version 9
App
release 1.3
schema_migrations table used to track versions
Friday, May 10, 2013
10. Database Migrations in Depth
Keep your database structure in sync in all environments
Development (Bleeding Edge)
Testing (Close to development or slightly behind)
Production (Behind testing and development)
Testing
Version 6
App
release 1.2
Development
Version 9
App
release 1.3
schema_migrations table used to track versions
Friday, May 10, 2013
11. Database Migrations in Depth
Keep your database structure in sync in all environments
Development (Bleeding Edge)
Testing (Close to development or slightly behind)
Production (Behind testing and development)
Production
Version 3
App
release 1.1
Testing
Version 6
App
release 1.2
Development
Version 9
App
release 1.3
schema_migrations table used to track versions
Friday, May 10, 2013
12. Data Seeding
Load preferences, lookups or other needed data
Friday, May 10, 2013
13. Data Seeding
Load preferences, lookups or other needed data
Seed data goes in db/seeds.rb
Friday, May 10, 2013
14. Data Seeding
Load preferences, lookups or other needed data
Seed data goes in db/seeds.rb
rake db:seed
Friday, May 10, 2013
17. Rails provides a set of default generators
“rails generate”or“rails generate --help”
Generators Overview
Generators create boilerplate code for pieces of your application
Friday, May 10, 2013
18. Rails provides a set of default generators
“rails generate”or“rails generate --help”
Generators Overview
Generators create boilerplate code for pieces of your application
Gems can provide generators and you can write your own custom
generators
Friday, May 10, 2013
20. Generating Models
Model generator creates an ActiveRecord model and a migration
Friday, May 10, 2013
21. Generating Models
Model generator creates an ActiveRecord model and a migration
Pass in attributes and their data types to leverage more code
generation
Friday, May 10, 2013
22. Generating Models
Model generator creates an ActiveRecord model and a migration
Pass in attributes and their data types to leverage more code
generation
rails generate model model_name attr1:string attr2:integer etc.
Friday, May 10, 2013
25. Generating Controllers
Controller generator will create a controller and folder stubs for its views
Pass in actions to have the generator create view stub files for the actions
Friday, May 10, 2013
26. Generating Controllers
Controller generator will create a controller and folder stubs for its views
Pass in actions to have the generator create view stub files for the actions
rails generate controller contr_name action1 action 2
Friday, May 10, 2013
28. Rails Console Overview
Interactive interpreter with your rails project loaded
Friday, May 10, 2013
29. Rails Console Overview
Interactive interpreter with your rails project loaded
Good way to become familiar with code or features or to debug
Friday, May 10, 2013
30. Rails Console Overview
Interactive interpreter with your rails project loaded
Start the rails console with the following command
rails console
rails console production
Good way to become familiar with code or features or to debug
Friday, May 10, 2013
32. Rails DB Console
A wrapper around your database console
Friday, May 10, 2013
33. Rails DB Console
A wrapper around your database console
An easy way to deal with MySQL, PostgreSQL and SQLite
Friday, May 10, 2013
34. Rails DB Console
A wrapper around your database console
Start the rails db console with the following command
rails dbconsole
rails dbconsole production -p
An easy way to deal with MySQL, PostgreSQL and SQLite
Friday, May 10, 2013
41. Asset Pipeline Overview
Framework for images, JS and CSS resources
Rails asset pipeline will auto minify and compress JS and CSS
Friday, May 10, 2013
42. Asset Pipeline Overview
Framework for images, JS and CSS resources
Rails asset pipeline will auto minify and compress JS and CSS
Asset pipeline supports enhanced languages such as CoffeeScript and
SASS
Friday, May 10, 2013