From fff0045b04f9c3358db482539a0b1ac547af31b2 Mon Sep 17 00:00:00 2001
From: "takatsugu.ishioka"
Date: Fri, 15 Jun 2012 23:01:53 +0900
Subject: [PATCH 1/4] =?UTF-8?q?memo=E3=83=A2=E3=83=87=E3=83=AB=E3=81=A8?=
=?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC=E3=83=A9=E3=82=92?=
=?UTF-8?q?generate?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
db/schema.rb | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/db/schema.rb b/db/schema.rb
index 5fc61c2..30bf75e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120526050801) do
+ActiveRecord::Schema.define(:version => 20120615135737) do
create_table "books", :force => true do |t|
t.string "title"
@@ -21,4 +21,11 @@
t.datetime "updated_at", :null => false
end
+ create_table "memos", :force => true do |t|
+ t.integer "book_id"
+ t.text "description"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
end
From f681c49e08faadc4e4ca536914364d200a0f554e Mon Sep 17 00:00:00 2001
From: "takatsugu.ishioka"
Date: Fri, 15 Jun 2012 23:06:04 +0900
Subject: [PATCH 2/4] =?UTF-8?q?Gemfile=E4=BF=AE=E6=AD=A3=20=E3=82=B3?=
=?UTF-8?q?=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC=E3=83=A9=E3=80=81=E3=83=93?=
=?UTF-8?q?=E3=83=A5=E3=83=BC=E3=82=92=E5=AE=9F=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Gemfile | 2 +-
Gemfile.lock | 4 ++++
app/controllers/books_controller.rb | 1 +
app/models/book.rb | 1 +
app/views/books/show.html.erb | 13 +++++++++++++
5 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Gemfile b/Gemfile
index d643000..dd7543e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -15,7 +15,7 @@ group :assets do
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
- # gem 'therubyracer', :platform => :ruby
+ gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f24858..1887036 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -67,6 +67,7 @@ GEM
json (1.7.3)
launchy (2.1.0)
addressable (~> 2.2.6)
+ libv8 (3.3.10.4)
libwebsocket (0.1.3)
addressable
mail (2.4.4)
@@ -140,6 +141,8 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
+ therubyracer (0.10.1)
+ libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -166,4 +169,5 @@ DEPENDENCIES
rspec-rails (~> 2.0)
sass-rails (~> 3.2.3)
sqlite3
+ therubyracer
uglifier (>= 1.0.3)
diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb
index d13ffd9..6c5be44 100644
--- a/app/controllers/books_controller.rb
+++ b/app/controllers/books_controller.rb
@@ -16,6 +16,7 @@ def index
# GET /books/1
# GET /books/1.json
def show
+ @memo = Memo.new
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @book }
diff --git a/app/models/book.rb b/app/models/book.rb
index 95c42dd..36ac641 100644
--- a/app/models/book.rb
+++ b/app/models/book.rb
@@ -1,6 +1,7 @@
# encoding: UTF-8
class Book < ActiveRecord::Base
attr_accessible :memo, :purchased_on, :title
+ has_many :memos, :dependent => :destroy
validates :title, :presence => true
before_create :total_books_count
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb
index 23005ab..6ce9c30 100644
--- a/app/views/books/show.html.erb
+++ b/app/views/books/show.html.erb
@@ -15,6 +15,19 @@
<%= @book.purchased_on %>
+
+ Description:
+<% @book.memos.each do |memo| %>
+ <%= link_to 'Remove', memo, confirm: 'Are you sure?', method: :delete %>
+
<%= memo.description %>
+
+
+<% end %>
+<%= form_for @memo, :url => book_memos_path(@book) do |f| %>
+ <%= f.text_area :description %>
+ <%= f.submit %>
+<% end %>
+
<%= link_to 'Edit', edit_book_path(@book) %> |
<%= link_to 'Back', books_path %>
From 9625f6dba959853e40f638ee20dfa0676a5e9271 Mon Sep 17 00:00:00 2001
From: "takatsugu.ishioka"
Date: Fri, 15 Jun 2012 23:09:35 +0900
Subject: [PATCH 3/4] =?UTF-8?q?routes.db=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/routes.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/config/routes.rb b/config/routes.rb
index f3d38ab..33ad653 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,10 @@
BookMemo2::Application.routes.draw do
- resources :books
+
+ resources :memos
+ resources :books do
+ resources :memos
+ end
# The priority is based upon order of creation:
# first created -> highest priority.
From af2a30c7c9b84319bcc7f3b7545c75d37dbade69 Mon Sep 17 00:00:00 2001
From: "takatsugu.ishioka"
Date: Fri, 15 Jun 2012 23:16:16 +0900
Subject: [PATCH 4/4] =?UTF-8?q?show.html.rb=E3=81=AEspec=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/books/show.html.erb | 4 ++--
spec/views/books/show.html.erb_spec.rb | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb
index 6ce9c30..c25810b 100644
--- a/app/views/books/show.html.erb
+++ b/app/views/books/show.html.erb
@@ -15,7 +15,7 @@
<%= @book.purchased_on %>
-
+
Description:
<% @book.memos.each do |memo| %>
<%= link_to 'Remove', memo, confirm: 'Are you sure?', method: :delete %>
@@ -28,6 +28,6 @@
<%= f.text_area :description %>
<%= f.submit %>
<% end %>
-
+
<%= link_to 'Edit', edit_book_path(@book) %> |
<%= link_to 'Back', books_path %>
diff --git a/spec/views/books/show.html.erb_spec.rb b/spec/views/books/show.html.erb_spec.rb
index 82d0e4b..012b0cc 100644
--- a/spec/views/books/show.html.erb_spec.rb
+++ b/spec/views/books/show.html.erb_spec.rb
@@ -6,12 +6,13 @@
:title => "Title",
:memo => "MyText"
))
+ @memo = Memo.new
end
it "renders attributes in " do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- rendered.should match(/Title/)
- rendered.should match(/MyText/)
+ rendered.should match(/Title/)
+ rendered.should match(/MyText/)
end
end