6.3 Iteration A2: Add a Missing Column 6.1 Iteration A1: Getting Something Running
ls -p
app/ config.ru doc/ lib/ public/ README test/ vendor/
config/ db/ Gemfile log/ Rakefile script/ tmp/
rails generate scaffold product title:string description:text image_url:string
invoke active_record
create db/migrate/20120629191040_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 20120629191040_create_products.rb 20110711000001_create_products.rb
== CreateProducts: migrating =================================================
-- create_table(:products)
-> 0.0030s
== CreateProducts: migrated (0.0032s) ========================================
sqlite3> select version from schema_migrations
version = 20110711000001
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
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
Finished in 0.152594 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
6.55 tests/s, 6.55 assertions/s
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
Finished in 0.501399 seconds.
7 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
13.96 tests/s, 19.94 assertions/s
6.3 Iteration A2: Add a Missing Column 6.1 Iteration A1: Getting Something Running