public
Fork of matthewford/book_mdar
Description: Life On The Edge With Merb, DataMapper & RSpec
Homepage: http://blog.new-bamboo.co.uk
Clone URL: git://github.com/kwatch/book_mdar.git
Translated Chapter 4-1 Introduction.
kwatch (author)
Tue Sep 23 04:55:12 -0700 2008
commit  a90fb4175f1b8c95b7b91c1f8dc8f3d6692d7375
tree    95b2b625b8c5685b4131f0bd0d8879b260ba80f5
parent  6051c61511517fc83d5f48c6dcf21a5b1cc9804e
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
0
@@ -0,0 +1,133 @@
0
+## A little blog (小さなブログ)
0
+
0
+#### What will be covered (この節で取り扱う内容)
0
+
0
+ * Setting up the example blog application
0
+ * Creating the models
0
+ * Configuring your routes
0
+ * RESTful controllers
0
+ * Some of the view helpers in `merb_helpers`
0
+ * Configuring and sending emails
0
+
0
+ * サンプルとなるブログアプリケーションの設定
0
+ * モデルの作成
0
+ * ルーティングの設定構成
0
+ * RESTful なコントローラ
0
+ * `merb_helpers` で定義されているビューヘルパのいくつか
0
+ * 電子メールの送信とそのための設定構成
0
+
0
+In the examples, we'll be developing a small blogging application. It's a good
0
+idea to grab the source code from [http://github.com/deimos1986/book_mdar/tree/master/code](http://github.com/deimos1986/book_mdar/tree/master/code), 
0
+so you can follow along with the examples.
0
+
0
+サンプルでは、小さいブログアプリケーションを作成します。
0
+ソースコードは [http://github.com/deimos1986/book_mdar/tree/master/code](http://github.com/deimos1986/book_mdar/tree/master/code) から取ってこれますので、サンプルに沿って試すことができます。
0
+
0
+First of all, let's define some of the functionality we would expect from any 
0
+blogging application. 
0
+
0
+まず最初に、ブログアプリケーションとして考えられる機能をいくつか定義しましょう。
0
+
0
+* Publishing posts
0
+* Leaving comments
0
+* Sending email notifications
0
+* Attaching images
0
+* Authentication
0
+
0
+* 投稿を公開する
0
+* コメントを残す
0
+* 電子メールで通知する
0
+* 画像を添付する
0
+* 認証する
0
+
0
+We're going to call our app `golb`. Think of it as a backward blog. Feel free 
0
+to change the name of your app, but if you do, remember to replace the word
0
+`golb` with the name of your app.
0
+
0
+このアプリケーションは、`golb` という名前にすることにします。
0
+バックワードのブログとして考えてください〔訳注: ???〕。
0
+アプリの名前は自由に変更して構いませんが、変更した場合は `golb` という単語が出てきたら変更後の名前に置き換えてください。
0
+
0
+To make a new app we'll use the command
0
+
0
+新しいアプリを作るには、次のコマンドを使います。
0
+
0
+    merb-gen app golb
0
+
0
+Set up the configuration files for your application, this lets Merb know what 
0
+gems to load for plugins and generators.
0
+
0
+自分のアプリケーションの設定構成ファイルを設定してください。
0
+そうすることで、プラグインやジェネレータでどの gems を読み込むのか、Merb は知ることができるようになります。
0
+
0
+`config/init.rb`
0
+
0
+    use_orm :datamapper
0
+
0
+    use_test :rspec
0
+
0
+    dependencies "dm-validations"
0
+
0
+
0
+Now add a `config/database.yml` file with the following:
0
+
0
+また `config/database.yml` ファイルを次のような内容で作成してください:
0
+
0
+    ---
0
+    # This is a sample database file for the DataMapper ORM
0
+    development: &defaults
0
+      # These are the settings for repository :default
0
+      adapter:  mysql
0
+      database: golb
0
+      encoding: utf8
0
+      username: root
0
+      password: 
0
+      host:     localhost
0
+
0
+      # Add more repositories
0
+      # repositories:
0
+      #   repo1:
0
+      #     adapter:  postgresql
0
+      #     database: sample_development
0
+      #     username: the_user
0
+      #     password: secrets
0
+      #     host:     localhost
0
+      #   repo2:
0
+      #     ...
0
+
0
+    test:
0
+      <<:       *defaults
0
+      database: golb_test
0
+
0
+      # repositories:
0
+      #   repo1:
0
+      #     database: sample_development
0
+
0
+    production:
0
+      <<:       *defaults
0
+      database: golb_production
0
+
0
+      # repositories:
0
+      #   repo1:
0
+      #     database: sample_development
0
+  
0
+  ---
0
+      
0
+      
0
+Note: DataMapper has a rake task to generate a default database.yml file:
0
+
0
+注意: DataMapper には、デフォルトの database.yml ファイルを生成する rake タスクが用意されています。
0
+    
0
+    dm:db:database_yaml
0
+    
0
+You can also put a database URI in development.rb (or other environments) just as easily:
0
+
0
+また development.rb (または他の環境設定ファイル) にデータベース URI を設定することも簡単です:
0
+
0
+    Merb::BootLoader.after_app_loads do
0
+      DataMapper.setup(:default, 'mysql://user:pass@localhost/database')
0
+    end
0
+      
0
+Now we're ready to rock and roll ...
0
+
0
+ここまできたら、ロックンロールする準備はできました...

Comments