• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Web appl using RoR 3.2.14


コミットメタ情報

リビジョンa95ea8c2b723c91b96fae973f9e13c47791d2691 (tree)
日時2013-08-27 23:23:04
作者stellecadente <yoichi.k@stel...>
コミッターstellecadente

ログメッセージ

added an association

変更サマリ

差分

--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,9 @@
11 class ApplicationController < ActionController::Base
2+ before_filter :detect_locale
23 protect_from_forgery
4+
5+ private
6+ def detect_locale
7+ I18n.locale = request.headers['Accept-Language'].scan(/^[a-z]{2}/).first
8+ end
39 end
--- a/app/controllers/blogs_controller.rb
+++ b/app/controllers/blogs_controller.rb
@@ -80,4 +80,14 @@ class BlogsController < ApplicationController
8080 format.json { head :no_content }
8181 end
8282 end
83+
84+ # Retrieve blogs associated with Mountains
85+ def belongs
86+ @blog = Blog.find(1)
87+ end
88+
89+ def hasmany
90+ @mountain = Mountain.where(:id => 1).first
91+ end
92+
8393 end
--- a/app/controllers/mountains_controller.rb
+++ b/app/controllers/mountains_controller.rb
@@ -2,10 +2,13 @@ class MountainsController < ApplicationController
22 # GET /mountains
33 # GET /mountains.json
44 def index
5- @mountains = Mountain.all
5+ # @mountains = Mountain.all
6+ @mountains = Mountain.order('id ASC').
7+ paginate(:page => params[:page], :per_page => 10)
68
79 respond_to do |format|
810 format.html # index.html.erb
11+ format.xml { render :xml => @mountains }
912 format.json { render json: @mountains }
1013 end
1114 end
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2,11 +2,14 @@ class UsersController < ApplicationController
22 # GET /users
33 # GET /users.json
44 def index
5- @users = User.all
5+ # @users = User.all
6+ @users = User.order('name ASC').
7+ paginate(:page => params[:page], :per_page => 3)
68
79 respond_to do |format|
810 format.html # index.html.erb
911 format.json { render json: @users }
12+ format.xml { render :xml => @users }
1013 end
1114 end
1215
--- a/app/models/blog.rb
+++ b/app/models/blog.rb
@@ -1,3 +1,4 @@
11 class Blog < ActiveRecord::Base
2- attr_accessible :body, :id, :issue_dt, :title, :user_id
2+ attr_accessible :body, :id, :issue_dt, :title, :user_id, :mountain_id
3+ belongs_to :mountain
34 end
--- a/app/models/mountain.rb
+++ b/app/models/mountain.rb
@@ -1,3 +1,4 @@
11 class Mountain < ActiveRecord::Base
22 attr_accessible :district, :elevation, :fl_100meizan, :fl_200meizan, :fl_300meizan, :fl_aizu, :fl_gumma, :fl_hana, :fl_hokkaido, :fl_kansai, :fl_kanto, :fl_kyuushuu, :fl_niigata, :fl_shikoku, :fl_shinhana, :fl_shinhyaku, :fl_tochigi, :fl_tohoku, :fl_utsukushima, :fl_yama1000, :fl_yamanashi, :id, :kana, :latitude, :longitude, :map025, :map050, :map200, :name1, :name2, :name3, :number_300meizan, :prefs, :uname
3+ has_many :blogs
34 end
--- a/app/models/mountains_blogs.rb
+++ b/app/models/mountains_blogs.rb
@@ -1,5 +1,5 @@
11 class MountainsBlogs < ActiveRecord::Base
2- belongs_to :mountain_id
3- belongs_to :brog_id
2+ belongs_to :mountain
3+ belongs_to :blog
44 # attr_accessible :title, :body
55 end
--- a/app/views/blogs/_form.html.erb
+++ b/app/views/blogs/_form.html.erb
@@ -20,6 +20,10 @@
2020 <%= f.text_field :user_id %>
2121 </div>
2222 <div class="field">
23+ <%= f.label :mountain_id %><br />
24+ <%= f.text_field :mountain_id %>
25+ </div>
26+ <div class="field">
2327 <%= f.label :issue_dt %><br />
2428 <%= f.datetime_select :issue_dt %>
2529 </div>
@@ -29,7 +33,7 @@
2933 </div>
3034 <div class="field">
3135 <%= f.label :body %><br />
32- <%= f.text_field :body %>
36+ <%= f.text_area :body, {:cols =>40, :rows =>3 } %>
3337 </div>
3438 <div class="actions">
3539 <%= f.submit %>
--- /dev/null
+++ b/app/views/blogs/belongs.html.erb
@@ -0,0 +1,22 @@
1+<h1>「<%= @blog.mountain.uname %>」のブログ</h1>
2+<p>
3+ id: <%= @blog.mountain.id %>
4+ 山域名: <%= @blog.mountain.district %>
5+ 所属都道府県名: <%= @blog.mountain.prefs %>
6+ <br />
7+ 百名山: <%= @blog.mountain.fl_100meizan %>
8+ 200名山: <%= @blog.mountain.fl_200meizan %>
9+ 300名山: <%= @blog.mountain.fl_300meizan %>
10+ 日本の山1000: <%= @blog.mountain.fl_yama1000 %>
11+ <br />
12+ 地勢図: <%= @blog.mountain.map200 %>
13+ 五万図: <%= @blog.mountain.map050 %>
14+ 二万五千図: <%= @blog.mountain.map025 %>
15+</p>
16+<hr />
17+<p id="notice"><%= notice %></p>
18+
19+<h3><%= @blog.title %></h3>
20+<p><%= @blog.body %></p>
21+<p>(<%= @blog.id %> | <%= @blog.issue_dt %>) </p>
22+
--- /dev/null
+++ b/app/views/blogs/hasmany.html.erb
@@ -0,0 +1,24 @@
1+<h1>「<%= @mountain.uname %>」のブログ</h1>
2+<p>
3+ id: <%= @mountain.id %>
4+ 山域名: <%= @mountain.district %>
5+ 所属都道府県名: <%= @mountain.prefs %>
6+ <br />
7+ 百名山: <%= @mountain.fl_100meizan %>
8+ 200名山: <%= @mountain.fl_200meizan %>
9+ 300名山: <%= @mountain.fl_300meizan %>
10+ 日本の山1000: <%= @mountain.fl_yama1000 %>
11+ <br />
12+ 地勢図: <%= @mountain.map200 %>
13+ 五万図: <%= @mountain.map050 %>
14+ 二万五千図: <%= @mountain.map025 %>
15+</p>
16+<hr />
17+<p id="notice"><%= notice %></p>
18+
19+<% @mountain.blogs.each do |blog| %>
20+ <h3><%= blog.title %></h3>
21+ <p> <%= blog.body %></p>
22+ <p>(<%= blog.id %> | <%= blog.issue_dt %>) </p>
23+<% end %>
24+
--- a/app/views/blogs/index.html.erb
+++ b/app/views/blogs/index.html.erb
@@ -1,9 +1,12 @@
11 <h1>Listing blogs</h1>
2+<%= link_to 'New Blog', new_blog_path %>
3+<hr />
24
35 <table>
46 <tr>
57 <th>Id</th>
68 <th>User</th>
9+ <th>Mountain</th>
710 <th>Issue dt</th>
811 <th>Title</th>
912 <th>Body</th>
@@ -16,6 +19,7 @@
1619 <tr>
1720 <td><%= blog.id %></td>
1821 <td><%= blog.user_id %></td>
22+ <td><%= blog.mountain_id %></td>
1923 <td><%= blog.issue_dt %></td>
2024 <td><%= blog.title %></td>
2125 <td><%= blog.body %></td>
@@ -28,4 +32,3 @@
2832
2933 <br />
3034
31-<%= link_to 'New Blog', new_blog_path %>
--- a/app/views/blogs/show.html.erb
+++ b/app/views/blogs/show.html.erb
@@ -11,6 +11,11 @@
1111 </p>
1212
1313 <p>
14+ <b>Mountain:</b>
15+ <%= @blog.mountain %>
16+</p>
17+
18+<p>
1419 <b>Issue dt:</b>
1520 <%= @blog.issue_dt %>
1621 </p>
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
11 <!DOCTYPE html>
22 <html>
33 <head>
4- <title>Kisuge</title>
4+ <title><%= t 'application.title' %></title>
55 <%= stylesheet_link_tag "application", :media => "all" %>
66 <%= javascript_include_tag "application" %>
77 <%= csrf_meta_tags %>
@@ -10,5 +10,7 @@
1010
1111 <%= yield %>
1212
13+<hr />
14+<p>Powered by Ruby on Rails</p>
1315 </body>
1416 </html>
--- /dev/null
+++ b/app/views/mountains/_form_index_long.html.erb
@@ -0,0 +1,89 @@
1+<h1>Listing mountains</h1>
2+
3+<table>
4+ <tr>
5+ <th>Id</th>
6+ <th>Uname</th>
7+ <th>Kana</th>
8+ <th>Name1</th>
9+ <th>Name2</th>
10+ <th>Name3</th>
11+ <th>Elevation</th>
12+ <th>Number 300meizan</th>
13+ <th>District</th>
14+ <th>Latitude</th>
15+ <th>Longitude</th>
16+ <th>Prefs</th>
17+ <th>Map200</th>
18+ <th>Map050</th>
19+ <th>Map025</th>
20+ <th>Fl yama1000</th>
21+ <th>Fl 100meizan</th>
22+ <th>Fl 200meizan</th>
23+ <th>Fl 300meizan</th>
24+ <th>Fl hana</th>
25+ <th>Fl shinhana</th>
26+ <th>Fl shinhyaku</th>
27+ <th>Fl kanto</th>
28+ <th>Fl kansai</th>
29+ <th>Fl kyuushuu</th>
30+ <th>Fl yamanashi</th>
31+ <th>Fl tohoku</th>
32+ <th>Fl niigata</th>
33+ <th>Fl utsukushima</th>
34+ <th>Fl aizu</th>
35+ <th>Fl hokkaido</th>
36+ <th>Fl shikoku</th>
37+ <th>Fl tochigi</th>
38+ <th>Fl gumma</th>
39+ <th></th>
40+ <th></th>
41+ <th></th>
42+ </tr>
43+
44+<% @mountains.each do |mountain| %>
45+ <tr>
46+ <td><%= mountain.id %></td>
47+ <td><%= mountain.uname %></td>
48+ <td><%= mountain.kana %></td>
49+ <td><%= mountain.name1 %></td>
50+ <td><%= mountain.name2 %></td>
51+ <td><%= mountain.name3 %></td>
52+ <td><%= mountain.elevation %></td>
53+ <td><%= mountain.number_300meizan %></td>
54+ <td><%= mountain.district %></td>
55+ <td><%= mountain.latitude %></td>
56+ <td><%= mountain.longitude %></td>
57+ <td><%= mountain.prefs %></td>
58+ <td><%= mountain.map200 %></td>
59+ <td><%= mountain.map050 %></td>
60+ <td><%= mountain.map025 %></td>
61+ <td><%= mountain.fl_yama1000 %></td>
62+ <td><%= mountain.fl_100meizan %></td>
63+ <td><%= mountain.fl_200meizan %></td>
64+ <td><%= mountain.fl_300meizan %></td>
65+ <td><%= mountain.fl_hana %></td>
66+ <td><%= mountain.fl_shinhana %></td>
67+ <td><%= mountain.fl_shinhyaku %></td>
68+ <td><%= mountain.fl_kanto %></td>
69+ <td><%= mountain.fl_kansai %></td>
70+ <td><%= mountain.fl_kyuushuu %></td>
71+ <td><%= mountain.fl_yamanashi %></td>
72+ <td><%= mountain.fl_tohoku %></td>
73+ <td><%= mountain.fl_niigata %></td>
74+ <td><%= mountain.fl_utsukushima %></td>
75+ <td><%= mountain.fl_aizu %></td>
76+ <td><%= mountain.fl_hokkaido %></td>
77+ <td><%= mountain.fl_shikoku %></td>
78+ <td><%= mountain.fl_tochigi %></td>
79+ <td><%= mountain.fl_gumma %></td>
80+ <td><%= link_to 'Show', mountain %></td>
81+ <td><%= link_to 'Edit', edit_mountain_path(mountain) %></td>
82+ <td><%= link_to 'Destroy', mountain, method: :delete, data: { confirm: 'Are you sure?' } %></td>
83+ </tr>
84+<% end %>
85+</table>
86+
87+<br />
88+
89+<%= link_to 'New Mountain', new_mountain_path %>
--- /dev/null
+++ b/app/views/mountains/_form_index_short.html.erb
@@ -0,0 +1,38 @@
1+<table>
2+ <thead>
3+ <tr>
4+ <th>ID</th>
5+ <th><%= t "attributes.uname" %></th>
6+ <th><%= t "attributes.elevation" %></th>
7+ <th><%= t "attributes.district" %></th>
8+ <th><%= t "attributes.number_300meizan" %></th>
9+ <th><%= t "attributes.100meizan" %></th>
10+ <th><%= t "attributes.200meizan" %></th>
11+ <th><%= t "attributes.300meizan" %></th>
12+ <th><%= t "attributes.yama1000" %></th>
13+ <th></th>
14+ <th></th>
15+ <th></th>
16+ </tr>
17+ </thead>
18+
19+ <tbody>
20+ <% @mountains.each do |mountain| %>
21+ <tr style="background-color:<%= cycle('#DDddDD', '#FFff99') %>">
22+ <td width=10 align=right><%= mountain.id %></td>
23+ <td width=140><%= mountain.uname %></td>
24+ <td><%= mountain.elevation %>m</td>
25+ <td><%= mountain.district %></td>
26+ <td width=10 align=right><%= mountain.number_300meizan %></td>
27+ <td><%= mountain.fl_100meizan %></td>
28+ <td><%= mountain.fl_200meizan %></td>
29+ <td><%= mountain.fl_300meizan %></td>
30+ <td><%= mountain.fl_yama1000 %></td>
31+ <td><%= link_to '表示', mountain %></td>
32+ <td><%= link_to '編集', edit_mountain_path(mountain) %></td>
33+ <td><%= link_to '削除', mountain, method: :delete, data: { confirm: '削除すると元に戻すことはできませんが、本当に削除しますか?' } %></td>
34+ </tr>
35+ <% end %>
36+ </tbody>
37+ <%= will_paginate @mountains %>
38+</table>
--- /dev/null
+++ "b/app/views/mountains/index.html - \343\202\263\343\203\224\343\203\274.erb"
@@ -0,0 +1,89 @@
1+<h1>Listing mountains</h1>
2+
3+<table>
4+ <tr>
5+ <th>Id</th>
6+ <th>Uname</th>
7+ <th>Kana</th>
8+ <th>Name1</th>
9+ <th>Name2</th>
10+ <th>Name3</th>
11+ <th>Elevation</th>
12+ <th>Number 300meizan</th>
13+ <th>District</th>
14+ <th>Latitude</th>
15+ <th>Longitude</th>
16+ <th>Prefs</th>
17+ <th>Map200</th>
18+ <th>Map050</th>
19+ <th>Map025</th>
20+ <th>Fl yama1000</th>
21+ <th>Fl 100meizan</th>
22+ <th>Fl 200meizan</th>
23+ <th>Fl 300meizan</th>
24+ <th>Fl hana</th>
25+ <th>Fl shinhana</th>
26+ <th>Fl shinhyaku</th>
27+ <th>Fl kanto</th>
28+ <th>Fl kansai</th>
29+ <th>Fl kyuushuu</th>
30+ <th>Fl yamanashi</th>
31+ <th>Fl tohoku</th>
32+ <th>Fl niigata</th>
33+ <th>Fl utsukushima</th>
34+ <th>Fl aizu</th>
35+ <th>Fl hokkaido</th>
36+ <th>Fl shikoku</th>
37+ <th>Fl tochigi</th>
38+ <th>Fl gumma</th>
39+ <th></th>
40+ <th></th>
41+ <th></th>
42+ </tr>
43+
44+<% @mountains.each do |mountain| %>
45+ <tr>
46+ <td><%= mountain.id %></td>
47+ <td><%= mountain.uname %></td>
48+ <td><%= mountain.kana %></td>
49+ <td><%= mountain.name1 %></td>
50+ <td><%= mountain.name2 %></td>
51+ <td><%= mountain.name3 %></td>
52+ <td><%= mountain.elevation %></td>
53+ <td><%= mountain.number_300meizan %></td>
54+ <td><%= mountain.district %></td>
55+ <td><%= mountain.latitude %></td>
56+ <td><%= mountain.longitude %></td>
57+ <td><%= mountain.prefs %></td>
58+ <td><%= mountain.map200 %></td>
59+ <td><%= mountain.map050 %></td>
60+ <td><%= mountain.map025 %></td>
61+ <td><%= mountain.fl_yama1000 %></td>
62+ <td><%= mountain.fl_100meizan %></td>
63+ <td><%= mountain.fl_200meizan %></td>
64+ <td><%= mountain.fl_300meizan %></td>
65+ <td><%= mountain.fl_hana %></td>
66+ <td><%= mountain.fl_shinhana %></td>
67+ <td><%= mountain.fl_shinhyaku %></td>
68+ <td><%= mountain.fl_kanto %></td>
69+ <td><%= mountain.fl_kansai %></td>
70+ <td><%= mountain.fl_kyuushuu %></td>
71+ <td><%= mountain.fl_yamanashi %></td>
72+ <td><%= mountain.fl_tohoku %></td>
73+ <td><%= mountain.fl_niigata %></td>
74+ <td><%= mountain.fl_utsukushima %></td>
75+ <td><%= mountain.fl_aizu %></td>
76+ <td><%= mountain.fl_hokkaido %></td>
77+ <td><%= mountain.fl_shikoku %></td>
78+ <td><%= mountain.fl_tochigi %></td>
79+ <td><%= mountain.fl_gumma %></td>
80+ <td><%= link_to 'Show', mountain %></td>
81+ <td><%= link_to 'Edit', edit_mountain_path(mountain) %></td>
82+ <td><%= link_to 'Destroy', mountain, method: :delete, data: { confirm: 'Are you sure?' } %></td>
83+ </tr>
84+<% end %>
85+</table>
86+
87+<br />
88+
89+<%= link_to 'New Mountain', new_mountain_path %>
--- a/app/views/mountains/index.html.erb
+++ b/app/views/mountains/index.html.erb
@@ -1,89 +1,7 @@
1-<h1>Listing mountains</h1>
1+<h1><%= t 'mountains.title.list' %></h1>
2+<%= link_to '新規作成', new_mountain_path %>
3+<hr />
24
3-<table>
4- <tr>
5- <th>Id</th>
6- <th>Uname</th>
7- <th>Kana</th>
8- <th>Name1</th>
9- <th>Name2</th>
10- <th>Name3</th>
11- <th>Elevation</th>
12- <th>Number 300meizan</th>
13- <th>District</th>
14- <th>Latitude</th>
15- <th>Longitude</th>
16- <th>Prefs</th>
17- <th>Map200</th>
18- <th>Map050</th>
19- <th>Map025</th>
20- <th>Fl yama1000</th>
21- <th>Fl 100meizan</th>
22- <th>Fl 200meizan</th>
23- <th>Fl 300meizan</th>
24- <th>Fl hana</th>
25- <th>Fl shinhana</th>
26- <th>Fl shinhyaku</th>
27- <th>Fl kanto</th>
28- <th>Fl kansai</th>
29- <th>Fl kyuushuu</th>
30- <th>Fl yamanashi</th>
31- <th>Fl tohoku</th>
32- <th>Fl niigata</th>
33- <th>Fl utsukushima</th>
34- <th>Fl aizu</th>
35- <th>Fl hokkaido</th>
36- <th>Fl shikoku</th>
37- <th>Fl tochigi</th>
38- <th>Fl gumma</th>
39- <th></th>
40- <th></th>
41- <th></th>
42- </tr>
5+<%= render 'form_index_short' %>
436
44-<% @mountains.each do |mountain| %>
45- <tr>
46- <td><%= mountain.id %></td>
47- <td><%= mountain.uname %></td>
48- <td><%= mountain.kana %></td>
49- <td><%= mountain.name1 %></td>
50- <td><%= mountain.name2 %></td>
51- <td><%= mountain.name3 %></td>
52- <td><%= mountain.elevation %></td>
53- <td><%= mountain.number_300meizan %></td>
54- <td><%= mountain.district %></td>
55- <td><%= mountain.latitude %></td>
56- <td><%= mountain.longitude %></td>
57- <td><%= mountain.prefs %></td>
58- <td><%= mountain.map200 %></td>
59- <td><%= mountain.map050 %></td>
60- <td><%= mountain.map025 %></td>
61- <td><%= mountain.fl_yama1000 %></td>
62- <td><%= mountain.fl_100meizan %></td>
63- <td><%= mountain.fl_200meizan %></td>
64- <td><%= mountain.fl_300meizan %></td>
65- <td><%= mountain.fl_hana %></td>
66- <td><%= mountain.fl_shinhana %></td>
67- <td><%= mountain.fl_shinhyaku %></td>
68- <td><%= mountain.fl_kanto %></td>
69- <td><%= mountain.fl_kansai %></td>
70- <td><%= mountain.fl_kyuushuu %></td>
71- <td><%= mountain.fl_yamanashi %></td>
72- <td><%= mountain.fl_tohoku %></td>
73- <td><%= mountain.fl_niigata %></td>
74- <td><%= mountain.fl_utsukushima %></td>
75- <td><%= mountain.fl_aizu %></td>
76- <td><%= mountain.fl_hokkaido %></td>
77- <td><%= mountain.fl_shikoku %></td>
78- <td><%= mountain.fl_tochigi %></td>
79- <td><%= mountain.fl_gumma %></td>
80- <td><%= link_to 'Show', mountain %></td>
81- <td><%= link_to 'Edit', edit_mountain_path(mountain) %></td>
82- <td><%= link_to 'Destroy', mountain, method: :delete, data: { confirm: 'Are you sure?' } %></td>
83- </tr>
84-<% end %>
85-</table>
867
87-<br />
88-
89-<%= link_to 'New Mountain', new_mountain_path %>
--- a/app/views/users/_form.html.erb
+++ b/app/views/users/_form.html.erb
@@ -53,7 +53,7 @@
5353 </div>
5454 <div class="field">
5555 <%= f.label :selfintro %><br />
56- <%= f.text_field :selfintro %>
56+ <%= f.text_area :selfintro, {:cols =>40, :rows =>3} %>
5757 </div>
5858 <div class="actions">
5959 <%= f.submit %>
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -1,6 +1,7 @@
11 <h1>Editing user</h1>
2+<%= link_to 'Show', @user %> |
3+<%= link_to 'Back', users_path %>
4+<hr />
25
36 <%= render 'form' %>
47
5-<%= link_to 'Show', @user %> |
6-<%= link_to 'Back', users_path %>
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,4 +1,7 @@
1-<h1>Listing users</h1>
1+<h1><%= t 'users.title.list' %></h1>
2+
3+<%= link_to 'New User', new_user_path %>
4+<hr />
25
36 <table>
47 <tr>
@@ -19,7 +22,7 @@
1922 </tr>
2023
2124 <% @users.each do |user| %>
22- <tr>
25+ <tr style="background-color:<%= cycle('#DDddDD', '#FFffBB') %>">
2326 <td><%= user.id %></td>
2427 <td><%= user.name %></td>
2528 <td><%= user.realname %></td>
@@ -36,8 +39,6 @@
3639 <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
3740 </tr>
3841 <% end %>
42+<%= will_paginate @users %>
3943 </table>
4044
41-<br />
42-
43-<%= link_to 'New User', new_user_path %>
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -1,5 +1,6 @@
11 <h1>New user</h1>
2+<%= link_to 'Back', users_path %>
3+<hr />
24
35 <%= render 'form' %>
46
5-<%= link_to 'Back', users_path %>
--- a/config/application.rb
+++ b/config/application.rb
@@ -31,7 +31,7 @@ module Kisuge
3131
3232 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
3333 # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34- # config.i18n.default_locale = :de
34+ config.i18n.default_locale = :jp
3535
3636 # Configure the default encoding used in templates for Ruby 1.9.
3737 config.encoding = "utf-8"
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,5 +1,212 @@
1-# Sample localization file for English. Add more files in this directory for other locales.
2-# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3-
41 en:
5- hello: "Hello world"
2+ date:
3+ abbr_day_names:
4+ - Sun
5+ - Mon
6+ - Tue
7+ - Wed
8+ - Thu
9+ - Fri
10+ - Sat
11+ abbr_month_names:
12+ -
13+ - Jan
14+ - Feb
15+ - Mar
16+ - Apr
17+ - May
18+ - Jun
19+ - Jul
20+ - Aug
21+ - Sep
22+ - Oct
23+ - Nov
24+ - Dec
25+ day_names:
26+ - Sunday
27+ - Monday
28+ - Tuesday
29+ - Wednesday
30+ - Thursday
31+ - Friday
32+ - Saturday
33+ formats:
34+ default: ! '%Y-%m-%d'
35+ long: ! '%B %d, %Y'
36+ short: ! '%b %d'
37+ month_names:
38+ -
39+ - January
40+ - February
41+ - March
42+ - April
43+ - May
44+ - June
45+ - July
46+ - August
47+ - September
48+ - October
49+ - November
50+ - December
51+ order:
52+ - :year
53+ - :month
54+ - :day
55+ datetime:
56+ distance_in_words:
57+ about_x_hours:
58+ one: about 1 hour
59+ other: about %{count} hours
60+ about_x_months:
61+ one: about 1 month
62+ other: about %{count} months
63+ about_x_years:
64+ one: about 1 year
65+ other: about %{count} years
66+ almost_x_years:
67+ one: almost 1 year
68+ other: almost %{count} years
69+ half_a_minute: half a minute
70+ less_than_x_minutes:
71+ one: less than a minute
72+ other: less than %{count} minutes
73+ less_than_x_seconds:
74+ one: less than 1 second
75+ other: less than %{count} seconds
76+ over_x_years:
77+ one: over 1 year
78+ other: over %{count} years
79+ x_days:
80+ one: 1 day
81+ other: ! '%{count} days'
82+ x_minutes:
83+ one: 1 minute
84+ other: ! '%{count} minutes'
85+ x_months:
86+ one: 1 month
87+ other: ! '%{count} months'
88+ x_seconds:
89+ one: 1 second
90+ other: ! '%{count} seconds'
91+ prompts:
92+ day: Day
93+ hour: Hour
94+ minute: Minute
95+ month: Month
96+ second: Seconds
97+ year: Year
98+ errors: &errors
99+ format: ! '%{attribute} %{message}'
100+ messages:
101+ accepted: must be accepted
102+ blank: can't be blank
103+ present: must be blank
104+ confirmation: ! "doesn't match %{attribute}"
105+ empty: can't be empty
106+ equal_to: must be equal to %{count}
107+ even: must be even
108+ exclusion: is reserved
109+ greater_than: must be greater than %{count}
110+ greater_than_or_equal_to: must be greater than or equal to %{count}
111+ inclusion: is not included in the list
112+ invalid: is invalid
113+ less_than: must be less than %{count}
114+ less_than_or_equal_to: must be less than or equal to %{count}
115+ not_a_number: is not a number
116+ not_an_integer: must be an integer
117+ odd: must be odd
118+ record_invalid: ! 'Validation failed: %{errors}'
119+ restrict_dependent_destroy:
120+ one: "Cannot delete record because a dependent %{record} exists"
121+ many: "Cannot delete record because dependent %{record} exist"
122+ taken: has already been taken
123+ too_long:
124+ one: is too long (maximum is 1 character)
125+ other: is too long (maximum is %{count} characters)
126+ too_short:
127+ one: is too short (minimum is 1 character)
128+ other: is too short (minimum is %{count} characters)
129+ wrong_length:
130+ one: is the wrong length (should be 1 character)
131+ other: is the wrong length (should be %{count} characters)
132+ other_than: "must be other than %{count}"
133+ template:
134+ body: ! 'There were problems with the following fields:'
135+ header:
136+ one: 1 error prohibited this %{model} from being saved
137+ other: ! '%{count} errors prohibited this %{model} from being saved'
138+ helpers:
139+ select:
140+ prompt: Please select
141+ submit:
142+ create: Create %{model}
143+ submit: Save %{model}
144+ update: Update %{model}
145+ number:
146+ currency:
147+ format:
148+ delimiter: ! ','
149+ format: ! '%u%n'
150+ precision: 2
151+ separator: .
152+ significant: false
153+ strip_insignificant_zeros: false
154+ unit: $
155+ format:
156+ delimiter: ! ','
157+ precision: 3
158+ separator: .
159+ significant: false
160+ strip_insignificant_zeros: false
161+ human:
162+ decimal_units:
163+ format: ! '%n %u'
164+ units:
165+ billion: Billion
166+ million: Million
167+ quadrillion: Quadrillion
168+ thousand: Thousand
169+ trillion: Trillion
170+ unit: ''
171+ format:
172+ delimiter: ''
173+ precision: 3
174+ significant: true
175+ strip_insignificant_zeros: true
176+ storage_units:
177+ format: ! '%n %u'
178+ units:
179+ byte:
180+ one: Byte
181+ other: Bytes
182+ gb: GB
183+ kb: KB
184+ mb: MB
185+ tb: TB
186+ percentage:
187+ format:
188+ delimiter: ''
189+ format: "%n%"
190+ precision:
191+ format:
192+ delimiter: ''
193+ support:
194+ array:
195+ last_word_connector: ! ', and '
196+ two_words_connector: ! ' and '
197+ words_connector: ! ', '
198+ time:
199+ am: am
200+ formats:
201+ default: ! '%a, %d %b %Y %H:%M:%S %z'
202+ long: ! '%B %d, %Y %H:%M'
203+ short: ! '%d %b %H:%M'
204+ pm: pm
205+ # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
206+ activemodel:
207+ errors:
208+ <<: *errors
209+ activerecord:
210+ errors:
211+ <<: *errors
212+
--- /dev/null
+++ b/config/locales/ja.yml
@@ -0,0 +1,316 @@
1+ja:
2+ date:
3+ abbr_day_names:
4+ - 日
5+ - 月
6+ - 火
7+ - 水
8+ - 木
9+ - 金
10+ - 土
11+ abbr_month_names:
12+ -
13+ - 1月
14+ - 2月
15+ - 3月
16+ - 4月
17+ - 5月
18+ - 6月
19+ - 7月
20+ - 8月
21+ - 9月
22+ - 10月
23+ - 11月
24+ - 12月
25+ day_names:
26+ - 日曜日
27+ - 月曜日
28+ - 火曜日
29+ - 水曜日
30+ - 木曜日
31+ - 金曜日
32+ - 土曜日
33+ formats:
34+ default: ! '%Y/%m/%d'
35+ long: ! '%Y年%m月%d日(%a)'
36+ short: ! '%m/%d'
37+ month_names:
38+ -
39+ - 1月
40+ - 2月
41+ - 3月
42+ - 4月
43+ - 5月
44+ - 6月
45+ - 7月
46+ - 8月
47+ - 9月
48+ - 10月
49+ - 11月
50+ - 12月
51+ order:
52+ - :year
53+ - :month
54+ - :day
55+ datetime:
56+ distance_in_words:
57+ about_x_hours:
58+ one: 約1時間
59+ other: 約%{count}時間
60+ about_x_months:
61+ one: 約1ヶ月
62+ other: 約%{count}ヶ月
63+ about_x_years:
64+ one: 約1年
65+ other: 約%{count}年
66+ almost_x_years:
67+ one: 1年弱
68+ other: ! '%{count}年弱'
69+ half_a_minute: 30秒前後
70+ less_than_x_minutes:
71+ one: 1分以内
72+ other: ! '%{count}分以内'
73+ less_than_x_seconds:
74+ one: 1秒以内
75+ other: ! '%{count}秒以内'
76+ over_x_years:
77+ one: 1年以上
78+ other: ! '%{count}年以上'
79+ x_days:
80+ one: 1日
81+ other: ! '%{count}日'
82+ x_minutes:
83+ one: 1分
84+ other: ! '%{count}分'
85+ x_months:
86+ one: 1ヶ月
87+ other: ! '%{count}ヶ月'
88+ x_seconds:
89+ one: 1秒
90+ other: ! '%{count}秒'
91+ prompts:
92+ day: 日
93+ hour: 時
94+ minute: 分
95+ month: 月
96+ second: 秒
97+ year: 年
98+ errors: &errors
99+ format: ! '%{attribute}%{message}'
100+ messages:
101+ accepted: を受諾してください。
102+ blank: を入力してください。
103+ present: は入力しないでください。
104+ confirmation: と%{attribute}の入力が一致しません。
105+ empty: を入力してください。
106+ equal_to: は%{count}にしてください。
107+ even: は偶数にしてください。
108+ exclusion: は予約されています。
109+ greater_than: は%{count}より大きい値にしてください。
110+ greater_than_or_equal_to: は%{count}以上の値にしてください。
111+ inclusion: は一覧にありません。
112+ invalid: は不正な値です。
113+ less_than: は%{count}より小さい値にしてください。
114+ less_than_or_equal_to: は%{count}以下の値にしてください。
115+ not_a_number: は数値で入力してください。
116+ not_an_integer: は整数で入力してください。
117+ odd: は奇数にしてください。
118+ record_invalid: バリデーションに失敗しました。 %{errors}
119+ restrict_dependent_destroy: ! '%{record}が存在しているので削除できません。'
120+ taken: はすでに存在します。
121+ too_long: は%{count}文字以内で入力してください。
122+ too_short: は%{count}文字以上で入力してください。
123+ wrong_length: は%{count}文字で入力してください。
124+ other_than: "は%{count}以外の値にしてください。"
125+ template:
126+ body: 次の項目を確認してください。
127+ header:
128+ one: ! '%{model}にエラーが発生しました。'
129+ other: ! '%{model}に%{count}個のエラーが発生しました。'
130+ helpers:
131+ select:
132+ prompt: 選択してください。
133+ submit:
134+ create: 登録する
135+ submit: 保存する
136+ save: 保存
137+ update: 更新する
138+ confirm: よろしいですか?
139+ disable_with: 処理中...
140+ link:
141+ back: 一覧へ戻る
142+ number:
143+ currency:
144+ format:
145+ delimiter: ! ','
146+ format: ! '%n%u'
147+ precision: 0
148+ separator: .
149+ significant: false
150+ strip_insignificant_zeros: false
151+ unit: 円
152+ format:
153+ delimiter: ! ','
154+ precision: 3
155+ separator: .
156+ significant: false
157+ strip_insignificant_zeros: false
158+ human:
159+ decimal_units:
160+ format: ! '%n %u'
161+ units:
162+ billion: 十億
163+ million: 百万
164+ quadrillion: 千兆
165+ thousand: 千
166+ trillion: 兆
167+ unit: ''
168+ format:
169+ delimiter: ''
170+ precision: 3
171+ significant: true
172+ strip_insignificant_zeros: true
173+ storage_units:
174+ format: ! '%n%u'
175+ units:
176+ byte: バイト
177+ gb: ギガバイト
178+ kb: キロバイト
179+ mb: メガバイト
180+ tb: テラバイト
181+ percentage:
182+ format:
183+ delimiter: ''
184+ format: "%n%"
185+ precision:
186+ format:
187+ delimiter: ''
188+ support:
189+ array:
190+ last_word_connector: と
191+ two_words_connector: と
192+ words_connector: と
193+ time:
194+ am: 午前
195+ formats:
196+ default: ! '%Y/%m/%d %H:%M:%S'
197+ long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z'
198+ short: ! '%y/%m/%d %H:%M'
199+ pm: 午後
200+ # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
201+ activemodel:
202+ errors:
203+ <<: *errors
204+ activerecord:
205+ errors:
206+ <<: *errors
207+ attributes:
208+ uname: 山名
209+ kana: よみがな
210+ elevation: 標高
211+ number_300meizan: 300名山通番
212+ name1: 呼称1
213+ name2: 呼称2
214+ name3: 呼称3
215+ district: '山域名'
216+ prefs: 所属都道府県
217+ latitude: 緯度
218+ longitude: 経度
219+ map20man: 地勢図
220+ map5man: 五万図
221+ map2man5sen: 二万五千図
222+ 100meizan: '百名山'
223+ 200meizan: '二百名山'
224+ 300meizan: '三百名山'
225+ yama1000: '山1000'
226+ fl_100meizan: 日本百名山
227+ fl_200meizenn: 二百名山
228+ fl_300meizan: 三百名山
229+ fl_yama1000: 日本の山1000
230+ fl_hana: 花の百名山
231+ fl_shinhana: 新・花の百名山
232+ fl_shinhyaku: 新百名山
233+ fl_kanto: 関東百名山
234+ fl_kansai: 関西百名山
235+ fl_kyuushuu: 九州百名山
236+ fl_yamanashi: 山梨百名山
237+ fl_tohoku: 東北百名山
238+ fl_niigata: 新潟百名山
239+ fl_utsukushima: うつくしま百名山
240+ fl_aizu: 会津百名山
241+ fl_hokkaido: 北海道百名山
242+ fl_shikoku: 四国百名山
243+ fl_tochigi: 栃木百名山
244+ fl_gumma: ぐんま百名山
245+ name: ログイン名
246+ handlename: ハンドル名
247+ realname: お名前
248+ password: パスワード
249+ email: Eメールアドレス
250+ register_d: 登録日
251+ birth_d: 生年月日
252+ publish_d: 公開日
253+ start_d: 開始日
254+ end_d: 終了日
255+ authority: 権限
256+ selfintro: 自己紹介
257+ title: 題名
258+ blog: ブログ
259+ body: 記事
260+ fl_publish: 公開サイン
261+ issue_dt: 公開日時
262+ member: お名前
263+ selfintro: 自己紹介
264+ msg:
265+ processing: '処理中...'
266+ back:
267+ link: '一覧表に戻る'
268+ delete:
269+ button: '削除'
270+ link: '削除'
271+ confirm: '削除すると元に戻すことはできませんが、削除しますか?'
272+ save:
273+ button: '保存'
274+ link: '保存'
275+ confirm: '保存してもよいですか?'
276+ show:
277+ link: '表示'
278+ edit:
279+ link: '編集'
280+ application:
281+ title: キスゲプロジェクト
282+ users:
283+ title:
284+ list: 〈メンバー〉データ一覧表
285+ edit: 〈メンバー〉データ編集
286+ new: 〈メンバー〉データ新規作成
287+ show: 〈メンバー〉データ表示
288+ mountains:
289+ title:
290+ list: 〈山〉データ一覧表
291+ edit: 〈山〉データ編集
292+ new: 〈山〉データ新規作成
293+ show: 〈山〉データ表示
294+ records:
295+ title:
296+ list: 〈記録〉データ一覧表
297+ edit: 〈記録〉データ編集
298+ new: 〈記録〉データ新規作成
299+ show: 〈記録〉データ表示
300+ blogs:
301+ title:
302+ list: 〈ブログ〉データ一覧表
303+ edit: 〈ブログ〉データ編集
304+ new: 〈ブログ〉データ新規作成
305+ show: 〈ブログ〉データ表示
306+ blog_comments:
307+ title:
308+ list: 〈ブログコメント〉データ一覧表
309+ edit: 〈ブログコメント〉データ編集
310+ new: 〈ブログコメント〉データ新規作成
311+ show: 〈ブログコメント〉データ表示
312+ will_paginate:
313+ previous_label: "&#8592; 前ページ"
314+ next_label: "次ページ &#8594;"
315+ page_gap: "&hellip;"
316+
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -7,9 +7,17 @@ Kisuge::Application.routes.draw do
77
88 resources :blog_comments
99
10-
11- resources :blogs
12-
10+ resources :blogs do
11+ collection do
12+ get 'belongs' => 'blogs#belongs'
13+ get 'hasmany' => 'blogs#hasmany'
14+ end
15+ get 'index'
16+ get 'show'
17+ post 'new'
18+ post 'edit'
19+ post 'destroy'
20+ end
1321
1422 resources :records
1523
--- a/create_scaffolds.sh
+++ b/create_scaffolds.sh
@@ -62,6 +62,7 @@ rails generate scaffold users \
6262 rails generate scaffold blogs \
6363 id:integer \
6464 user_id:string \
65+ mountain_id:integer \
6566 issue_dt:datetime \
6667 title:string \
6768 body:string \
@@ -76,6 +77,6 @@ rails generate scaffold blog-comments \
7677 body:string \
7778
7879 rails generate model mountains-blogs \
79- mountain_id:references \
80- brog_id:references \
80+ mountain:references \
81+ blog:references \
8182
--- a/db/migrate/20130827035159_create_blogs.rb
+++ b/db/migrate/20130827035158_create_blogs.rb
@@ -3,6 +3,7 @@ class CreateBlogs < ActiveRecord::Migration
33 create_table :blogs do |t|
44 t.integer :id
55 t.string :user_id
6+ t.integer :mountain_id
67 t.datetime :issue_dt
78 t.string :title
89 t.string :body
--- a/db/migrate/20130827061440_create_mountains_blogs.rb
+++ /dev/null
@@ -1,11 +0,0 @@
1-class CreateMountainsBlogs < ActiveRecord::Migration
2- def change
3- create_table :mountains_blogs, :id => false do |t|
4- t.references :mountain_id
5- t.references :brog_id
6-
7- end
8- add_index :mountains_blogs, :mountain_id_id
9- add_index :mountains_blogs, :brog_id_id
10- end
11-end
--- /dev/null
+++ b/db/migrate/20130827105699_create_mountains_blogs.rb
@@ -0,0 +1,11 @@
1+class CreateMountainsBlogs < ActiveRecord::Migration
2+ def change
3+ create_table :mountains_blogs, :id => false do |t|
4+ t.references :mountain
5+ t.references :blog
6+
7+ end
8+ add_index :mountains_blogs, :mountain_id
9+ add_index :mountains_blogs, :blog_id
10+ end
11+end
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
1111 #
1212 # It's strongly recommended to check this file into your version control system.
1313
14-ActiveRecord::Schema.define(:version => 20130827061440) do
14+ActiveRecord::Schema.define(:version => 20130827105700) do
1515
1616 create_table "blog_comments", :force => true do |t|
1717 t.integer "blog_id"
@@ -26,11 +26,12 @@ ActiveRecord::Schema.define(:version => 20130827061440) do
2626
2727 create_table "blogs", :force => true do |t|
2828 t.string "user_id"
29+ t.integer "mountain_id"
2930 t.datetime "issue_dt"
3031 t.string "title"
3132 t.string "body"
32- t.datetime "created_at", :null => false
33- t.datetime "updated_at", :null => false
33+ t.datetime "created_at", :null => false
34+ t.datetime "updated_at", :null => false
3435 end
3536
3637 create_table "mountains", :force => true do |t|
@@ -72,12 +73,12 @@ ActiveRecord::Schema.define(:version => 20130827061440) do
7273 end
7374
7475 create_table "mountains_blogs", :id => false, :force => true do |t|
75- t.integer "mountain_id_id"
76- t.integer "brog_id_id"
76+ t.integer "mountain_id"
77+ t.integer "blog_id"
7778 end
7879
79- add_index "mountains_blogs", ["brog_id_id"], :name => "index_mountains_blogs_on_brog_id_id"
80- add_index "mountains_blogs", ["mountain_id_id"], :name => "index_mountains_blogs_on_mountain_id_id"
80+ add_index "mountains_blogs", ["blog_id"], :name => "index_mountains_blogs_on_blog_id"
81+ add_index "mountains_blogs", ["mountain_id"], :name => "index_mountains_blogs_on_mountain_id"
8182
8283 create_table "records", :force => true do |t|
8384 t.string "mountain_id"
--- a/test/fixtures/_mountains_blogs.yml_
+++ /dev/null
@@ -1,9 +0,0 @@
1-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2-
3-one:
4- mountain_id:
5- brog_id:
6-
7-two:
8- mountain_id:
9- brog_id:
--- a/test/fixtures/blogs.yml
+++ b/test/fixtures/blogs.yml
@@ -2,14 +2,16 @@
22
33 one:
44 id: 1
5- user_id: MyString
6- issue_dt: 2013-08-27 12:51:59
5+ user_id: yoichi.k
6+ mountain_id: 1
7+ issue_dt: 2012-05-20 10:00:00
78 title: MyString
89 body: MyString
910
1011 two:
1112 id: 2
12- user_id: MyString
13+ user_id: yoichi.k
14+ mountain_id: 1
1315 issue_dt: 2013-08-27 12:51:59
1416 title: MyString
1517 body: MyString
--- /dev/null
+++ b/test/fixtures/mountains_blogs.yml
@@ -0,0 +1,17 @@
1+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+one:
4+ mountain_id: 1
5+ blog_id: 1
6+
7+two:
8+ mountain_id: 1
9+ blog_id: 2
10+
11+three:
12+ mountain_id: 1
13+ blog_id: 3
14+
15+four:
16+ mountain_id: 1
17+ blog_id: 4
--- a/test/functional/blogs_controller_test.rb
+++ b/test/functional/blogs_controller_test.rb
@@ -18,7 +18,7 @@ class BlogsControllerTest < ActionController::TestCase
1818
1919 test "should create blog" do
2020 assert_difference('Blog.count') do
21- post :create, blog: { body: @blog.body, id: @blog.id, issue_dt: @blog.issue_dt, title: @blog.title, user_id: @blog.user_id }
21+ post :create, blog: { body: @blog.body, id: @blog.id, issue_dt: @blog.issue_dt, title: @blog.title, user_id: @blog.user_id mountain_id: @blog.mountain_id }
2222 end
2323
2424 assert_redirected_to blog_path(assigns(:blog))
@@ -35,7 +35,7 @@ class BlogsControllerTest < ActionController::TestCase
3535 end
3636
3737 test "should update blog" do
38- put :update, id: @blog, blog: { body: @blog.body, id: @blog.id, issue_dt: @blog.issue_dt, title: @blog.title, user_id: @blog.user_id }
38+ put :update, id: @blog, blog: { body: @blog.body, id: @blog.id, issue_dt: @blog.issue_dt, title: @blog.title, user_id: @blog.user_id mountain_id: @blog.mountain_id }
3939 assert_redirected_to blog_path(assigns(:blog))
4040 end
4141