[ap4r-devel] [255] branches/200709_gihyo/async_shop/as_rails: Modified: ActiveRecord transaction and flash notice.
kato-k at rubyforge.org
kato-k at rubyforge.org
Fri Aug 24 01:44:46 EDT 2007
Revision: 255
Author: kato-k
Date: 2007-08-24 01:44:45 -0400 (Fri, 24 Aug 2007)
Log Message:
-----------
Modified: ActiveRecord transaction and flash notice.
Modified Paths:
--------------
branches/200709_gihyo/async_shop/as_rails/app/controllers/async_shop_controller.rb
branches/200709_gihyo/async_shop/as_rails/app/views/async_shop/list.rhtml
Added Paths:
-----------
branches/200709_gihyo/async_shop/as_rails/app/views/layouts/async_shop.rhtml
branches/200709_gihyo/async_shop/as_rails/public/stylesheets/scaffold.css
Modified: branches/200709_gihyo/async_shop/as_rails/app/controllers/async_shop_controller.rb
===================================================================
--- branches/200709_gihyo/async_shop/as_rails/app/controllers/async_shop_controller.rb 2007-08-24 01:47:11 UTC (rev 254)
+++ branches/200709_gihyo/async_shop/as_rails/app/controllers/async_shop_controller.rb 2007-08-24 05:44:45 UTC (rev 255)
@@ -15,13 +15,17 @@
def order
begin
- @order = Order.new(params[:order])
- @order.save
- payment(@order[:id])
+ ActiveRecord::Base.transaction do
+ @order = Order.new(params[:order])
+ @order.save
+ raise Exception
+ payment(@order[:id])
- flash[:notice] = 'Order was successfully created.'
- redirect_to :action => 'list'
- rescue Error
+ flash[:notice] = 'Order was successfully created.'
+ redirect_to :action => 'list'
+ end
+ rescue Exception
+ flash[:notice] = 'Order was failed.'
render :action => 'new'
end
end
Modified: branches/200709_gihyo/async_shop/as_rails/app/views/async_shop/list.rhtml
===================================================================
--- branches/200709_gihyo/async_shop/as_rails/app/views/async_shop/list.rhtml 2007-08-24 01:47:11 UTC (rev 254)
+++ branches/200709_gihyo/async_shop/as_rails/app/views/async_shop/list.rhtml 2007-08-24 05:44:45 UTC (rev 255)
@@ -11,7 +11,7 @@
<tr>
<td><%=h order.item %></td>
<td><%=h order.created_at %></td>
- <td><%=h Payment.find(order.id).created_at %></td>
+ <td><%=h begin Payment.find(order.id).created_at rescue "not yet." end %></td>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => order }, :confirm => 'Are you sure?', :method => :post %></td>
</tr>
<% end %>
Added: branches/200709_gihyo/async_shop/as_rails/app/views/layouts/async_shop.rhtml
===================================================================
--- branches/200709_gihyo/async_shop/as_rails/app/views/layouts/async_shop.rhtml (rev 0)
+++ branches/200709_gihyo/async_shop/as_rails/app/views/layouts/async_shop.rhtml 2007-08-24 05:44:45 UTC (rev 255)
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>AsyncShop: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>
Added: branches/200709_gihyo/async_shop/as_rails/public/stylesheets/scaffold.css
===================================================================
--- branches/200709_gihyo/async_shop/as_rails/public/stylesheets/scaffold.css (rev 0)
+++ branches/200709_gihyo/async_shop/as_rails/public/stylesheets/scaffold.css 2007-08-24 05:44:45 UTC (rev 255)
@@ -0,0 +1,74 @@
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
+div.uploadStatus {
+ margin: 5px;
+}
+
+div.progressBar {
+ margin: 5px;
+}
+
+div.progressBar div.border {
+ background-color: #fff;
+ border: 1px solid grey;
+ width: 100%;
+}
+
+div.progressBar div.background {
+ background-color: #333;
+ height: 18px;
+ width: 0%;
+}
+
More information about the ap4r-devel
mailing list