6.3 Iteration A2: Add a Missing Column 6.1 Iteration A1: Getting Something Running
ls -p
app/ config.ru doc/ Gemfile.lock log/ Rakefile script/ tmp/
config/ db/ Gemfile lib/ public/ README test/ vendor/
rails generate scaffold product title:string description:text image_url:string
invoke active_record
create db/migrate/20100807131332_create_products.rb
create app/models/product.rb
invoke test_unit
create test/unit/product_test.rb
create test/fixtures/products.yml
route resources :products
invoke scaffold_controller
create app/controllers/products_controller.rb
invoke erb
create app/views/products
create app/views/products/index.html.erb
create app/views/products/edit.html.erb
create app/views/products/show.html.erb
create app/views/products/new.html.erb
create app/views/products/_form.html.erb
invoke test_unit
create test/functional/products_controller_test.rb
invoke helper
create app/helpers/products_helper.rb
invoke test_unit
create test/unit/helpers/products_helper_test.rb
invoke stylesheets
create public/stylesheets/scaffold.css
rake db:migrate
mv 20100807131332_create_products.rb 20100301000001_create_products.rb
(in /home/rubys/git/awdwr/work-188/depot)
== CreateProducts: migrating =================================================
-- create_table(:products)
-> 0.0019s
== CreateProducts: migrated (0.0021s) ========================================
sqlite3> select version from schema_migrations
version = 20100301000001
edit app/views/products/_form.html.erb
<%= form_for(@product) do |f| %>
<% if @product.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
<ul>
<% @product.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description, :rows => 6 %>
</div>
<div class="field">
<%= f.label :image_url %><br />
<%= f.text_field :image_url %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
get /products
get /products/new
post /products
get http://localhost:3000/products/1
Product was successfully created.
Title: Pragmatic Version Control
Description: <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p>
Image url: /images/svn.jpg
Edit | Backget /products
Title | Description | Image url | |||
---|---|---|---|---|---|
Pragmatic Version Control | <p> This book is a recipe-based approach to using Subversion that will get you up and running quickly---and correctly. All projects need version control: it's a foundational piece of any project's infrastructure. Yet half of all project teams in the U.S. dont use any version control at all. Many others dont use it well, and end up experiencing time-consuming problems. </p> | /images/svn.jpg | Show | Edit | Destroy |
sqlite3 db/development.sqlite3 .schema
CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "image_url" varchar(255), "created_at" datetime, "updated_at" datetime);
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
rake test
(in /home/rubys/git/awdwr/work-188/depot)
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28862/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.016163 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.8-r28862/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.557935 seconds.
7 tests, 10 assertions, 0 failures, 0 errors
6.3 Iteration A2: Add a Missing Column 6.1 Iteration A1: Getting Something Running