ava_rails_generator 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -0
- data/USAGE +27 -0
- data/VERSION +1 -0
- data/ava_rails_generator.rb +201 -0
- data/templates/001_create_sessions.rb +16 -0
- data/templates/002_create_users.rb +20 -0
- data/templates/action_view_helper.rb +35 -0
- data/templates/action_view_ja.yml +115 -0
- data/templates/active_record_ja.yml +66 -0
- data/templates/active_support_ja.yml +36 -0
- data/templates/ann_back.png +0 -0
- data/templates/ann_back02.png +0 -0
- data/templates/application.html.erb +35 -0
- data/templates/application.js +128 -0
- data/templates/application_controller.rb +90 -0
- data/templates/application_csv.rb +66 -0
- data/templates/application_helper.rb +558 -0
- data/templates/application_search.rb +74 -0
- data/templates/arrow_h.gif +0 -0
- data/templates/arrow_l.png +0 -0
- data/templates/arrow_n.gif +0 -0
- data/templates/arrow_r.png +0 -0
- data/templates/arrow_v.gif +0 -0
- data/templates/auth_controller.rb +80 -0
- data/templates/bak.png +0 -0
- data/templates/btn_back.png +0 -0
- data/templates/btn_cancel_cre.png +0 -0
- data/templates/btn_cancel_upd.png +0 -0
- data/templates/btn_clear.png +0 -0
- data/templates/btn_close.png +0 -0
- data/templates/btn_complete.png +0 -0
- data/templates/btn_confirm_cre.png +0 -0
- data/templates/btn_confirm_upd.png +0 -0
- data/templates/btn_create.png +0 -0
- data/templates/btn_csv.png +0 -0
- data/templates/btn_delete.png +0 -0
- data/templates/btn_login.png +0 -0
- data/templates/btn_new.png +0 -0
- data/templates/btn_reenter.png +0 -0
- data/templates/btn_reload.png +0 -0
- data/templates/btn_reply.png +0 -0
- data/templates/btn_search.png +0 -0
- data/templates/btn_send.png +0 -0
- data/templates/btn_sub01.png +0 -0
- data/templates/btn_sub02.png +0 -0
- data/templates/btn_upd.png +0 -0
- data/templates/btn_upd_cancel.png +0 -0
- data/templates/btn_update.png +0 -0
- data/templates/btn_xml.png +0 -0
- data/templates/bubble_ex_g.png +0 -0
- data/templates/bubble_ex_p.png +0 -0
- data/templates/bubble_minus.gif +0 -0
- data/templates/bubble_plus.gif +0 -0
- data/templates/builder.js +136 -0
- data/templates/calendar.gif +0 -0
- data/templates/csv.rb +997 -0
- data/templates/default.css +92 -0
- data/templates/footer_a_bak.gif +0 -0
- data/templates/footer_m_bak.gif +0 -0
- data/templates/footer_w_bak.gif +0 -0
- data/templates/form.css +105 -0
- data/templates/g_navi_bak.gif +0 -0
- data/templates/import.css +13 -0
- data/templates/index.html.erb +8 -0
- data/templates/jquery-1.4.4.min.js +167 -0
- data/templates/jquery-ui-1.8.10.custom.css +573 -0
- data/templates/jquery-ui-1.8.10.custom.min.js +782 -0
- data/templates/jquery.ui.datepicker-ja.js +23 -0
- data/templates/layout.css +938 -0
- data/templates/link.gif +0 -0
- data/templates/link_t.gif +0 -0
- data/templates/login.html.erb +64 -0
- data/templates/login_back01.png +0 -0
- data/templates/logo.png +0 -0
- data/templates/mail.png +0 -0
- data/templates/menuTabL.gif +0 -0
- data/templates/menuTabR.gif +0 -0
- data/templates/navis.gif +0 -0
- data/templates/pageTitle_bak.png +0 -0
- data/templates/page_bak.gif +0 -0
- data/templates/password.html.erb +69 -0
- data/templates/pop.png +0 -0
- data/templates/prototype.js +6081 -0
- data/templates/rails.png +0 -0
- data/templates/scaffold.css +110 -0
- data/templates/scriptaculous.js +68 -0
- data/templates/slider.js +275 -0
- data/templates/sound.js +59 -0
- data/templates/tip.png +0 -0
- data/templates/tolist.png +0 -0
- data/templates/top_controller.rb +5 -0
- data/templates/translation_ja.yml +30 -0
- data/templates/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/templates/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/templates/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/templates/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/templates/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/templates/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/templates/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/templates/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/templates/ui-icons_217bc0_256x240.png +0 -0
- data/templates/ui-icons_2e83ff_256x240.png +0 -0
- data/templates/ui-icons_469bdd_256x240.png +0 -0
- data/templates/ui-icons_6da8d5_256x240.png +0 -0
- data/templates/ui-icons_cd0a0a_256x240.png +0 -0
- data/templates/ui-icons_d8e7f3_256x240.png +0 -0
- data/templates/ui-icons_f9bd01_256x240.png +0 -0
- data/templates/unittest.js +568 -0
- data/templates/user.rb +71 -0
- data/templates/user_blue.css +62 -0
- data/templates/user_green.css +61 -0
- data/templates/user_red.css +61 -0
- metadata +254 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Masaki Ozawa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= ava_rails_generator
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to ava_rails_generator
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Masaki Ozawa. See MIT-LICENSE for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ava_rails_generator"
|
18
|
+
gem.homepage = "http://github.com/ozamasa/ava_rails_generator"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{rails generator for avasys}
|
21
|
+
gem.description = %Q{rails generator for avasys corp.}
|
22
|
+
gem.email = "ozamasa123@gmail.com"
|
23
|
+
gem.authors = ["Masaki Ozawa"]
|
24
|
+
gem.files = Rake::FileList.new('*.rb', '[L-V]*', 'templates/*')
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
test.rcov_opts << '--exclude "gems/*"'
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rdoc/task'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "ava_rails_generator #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('*.rb')
|
54
|
+
end
|
data/USAGE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire resource, from model and migration to controller and
|
3
|
+
views, along with a full test suite. The resource is ready to use as a
|
4
|
+
starting point for your RESTful, resource-oriented application.
|
5
|
+
|
6
|
+
Pass the name of the model (in singular form), either CamelCased or
|
7
|
+
under_scored, as the first argument, and an optional list of attribute
|
8
|
+
pairs.
|
9
|
+
|
10
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
11
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
12
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
13
|
+
|
14
|
+
You don't have to think up every attribute up front, but it helps to
|
15
|
+
sketch out a few so you can start working with the resource immediately.
|
16
|
+
|
17
|
+
For example, 'ava_rails post '
|
18
|
+
gives you a model with those three attributes, a controller that handles
|
19
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
20
|
+
an index that lists them all, as well as a map.resources :posts
|
21
|
+
declaration in config/routes.rb.
|
22
|
+
|
23
|
+
If you want to remove all the generated files, run
|
24
|
+
'script/destroy ava_rails ApplicationName CompanyName'.
|
25
|
+
|
26
|
+
Examples:
|
27
|
+
`./script/generate ava_rails application_name company_name`
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,201 @@
|
|
1
|
+
class AvaRailsGenerator < Rails::Generator::NamedBase
|
2
|
+
default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false
|
3
|
+
|
4
|
+
attr_reader :app_color
|
5
|
+
|
6
|
+
def initialize(runtime_args, runtime_options = {})
|
7
|
+
super
|
8
|
+
|
9
|
+
@app_title = runtime_args.size > 0 ? runtime_args[0] : "built-in application name #TODO"
|
10
|
+
@app_company = runtime_args.size > 1 ? runtime_args[1] : "built-in company name #TODO"
|
11
|
+
@app_color = runtime_args.size > 2 ? runtime_args[2] : "blue"
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def manifest
|
16
|
+
record do |m|
|
17
|
+
# Controller, helper, views, test and stylesheets directories.
|
18
|
+
m.directory('app/models')
|
19
|
+
m.directory('app/helpers')
|
20
|
+
m.directory('app/views/top')
|
21
|
+
m.directory('app/views/auth')
|
22
|
+
m.directory('app/views/layouts')
|
23
|
+
m.directory('public/stylesheets')
|
24
|
+
m.directory('public/javascripts')
|
25
|
+
m.directory('db/migrate')
|
26
|
+
|
27
|
+
# Layout and stylesheet.
|
28
|
+
m.file('application_controller.rb', 'app/controllers/application_controller.rb')
|
29
|
+
m.file('auth_controller.rb', 'app/controllers/auth_controller.rb')
|
30
|
+
m.file('top_controller.rb', 'app/controllers/top_controller.rb')
|
31
|
+
m.file('application_search.rb', 'app/models/application_search.rb')
|
32
|
+
m.file('user.rb', 'app/models/user.rb')
|
33
|
+
m.template('index.html.erb', 'app/views/top/index.html.erb')
|
34
|
+
m.template('login.html.erb', 'app/views/auth/login.html.erb')
|
35
|
+
m.template('password.html.erb', 'app/views/auth/password.html.erb')
|
36
|
+
m.template('application.html.erb', 'app/views/layouts/application.html.erb')
|
37
|
+
|
38
|
+
m.file('application_helper.rb', 'app/helpers/application_helper.rb')
|
39
|
+
|
40
|
+
m.file('action_view_helper.rb', 'lib/action_view_helper.rb')
|
41
|
+
m.file('csv.rb', 'lib/csv.rb')
|
42
|
+
m.file('application_csv.rb', 'lib/application_csv.rb')
|
43
|
+
|
44
|
+
m.file('active_support_ja.yml', 'config/locales/active_support_ja.yml')
|
45
|
+
m.file('active_record_ja.yml', 'config/locales/active_record_ja.yml')
|
46
|
+
m.file('action_view_ja.yml', 'config/locales/action_view_ja.yml')
|
47
|
+
m.file('translation_ja.yml', 'config/locales/translation_ja.yml')
|
48
|
+
|
49
|
+
m.file('001_create_sessions.rb', 'db/migrate/001_create_sessions.rb')
|
50
|
+
m.file('002_create_users.rb', 'db/migrate/002_create_users.rb')
|
51
|
+
|
52
|
+
Dir.glob(source_path('*.css')).each {|f|
|
53
|
+
m.file(File.basename(f), File.join('public/stylesheets', File.basename(f)))
|
54
|
+
}
|
55
|
+
|
56
|
+
Dir.glob(source_path('*.js')).each {|f|
|
57
|
+
m.file(File.basename(f), File.join('public/javascripts', File.basename(f)))
|
58
|
+
}
|
59
|
+
|
60
|
+
Dir.glob(source_path('*.gif')).each {|f|
|
61
|
+
m.file(File.basename(f), File.join('public/images', File.basename(f)))
|
62
|
+
}
|
63
|
+
|
64
|
+
Dir.glob(source_path('*.png')).each {|f|
|
65
|
+
m.file(File.basename(f), File.join('public/images', File.basename(f)))
|
66
|
+
}
|
67
|
+
|
68
|
+
File.rename('public/index.html', 'public/index.html.org') if File.exist?('public/index.html')
|
69
|
+
|
70
|
+
# environment.rb
|
71
|
+
sentinel = "require File.join(File.dirname(__FILE__), 'boot')\n\nRails"
|
72
|
+
m.gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
73
|
+
s = <<'EOS'
|
74
|
+
|
75
|
+
|
76
|
+
# warning version_requirements is deprecated
|
77
|
+
if Gem::VERSION >= "1.3.6"
|
78
|
+
module Rails
|
79
|
+
class GemDependency
|
80
|
+
def requirement
|
81
|
+
r = super
|
82
|
+
(r == Gem::Requirement.default) ? nil : r
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
EOS
|
89
|
+
match.gsub("\n\n", s)
|
90
|
+
end
|
91
|
+
|
92
|
+
sentinel = " config.time_zone = 'UTC'"
|
93
|
+
m.gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
94
|
+
match.gsub(" config", " # commentout default timezone \n # config")
|
95
|
+
end
|
96
|
+
|
97
|
+
sentinel = " # config.i18n.default_locale = :de\nend"
|
98
|
+
m.gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
99
|
+
s = <<"EOS"
|
100
|
+
|
101
|
+
# set default locale
|
102
|
+
config.i18n.default_locale = 'ja'
|
103
|
+
|
104
|
+
# set migration filename
|
105
|
+
config.active_record.timestamped_migrations = false
|
106
|
+
|
107
|
+
# set colorize logging
|
108
|
+
config.active_record.colorize_logging = false
|
109
|
+
|
110
|
+
# set will_paginate
|
111
|
+
config.gem 'mislav-will_paginate', :lib => 'will_paginate', :version => '~> 2.3'
|
112
|
+
|
113
|
+
# set constant values
|
114
|
+
REGEXP_ZENKAKU = /^[^ -~?-゚]*$/ # zenkaku
|
115
|
+
REGEXP_HANKAKU = /^[ -~?-゚]*$/ # hankaku
|
116
|
+
REGEXP_EMAIL = /^[\w\.\-]+@(?:[\w\-]+\.)+[\w\-]+$/ # mail
|
117
|
+
REGEXP_ZIP = /^\d{3}-?\d{4}$/ # zip
|
118
|
+
REGEXP_TEL = /^\d+-?\d+-?\d+$/ # tel
|
119
|
+
REGEXP_PASSWORD= /^(?=.{8,})(?=.*[a-zA-Z]+)(?=.*[\d]+)[0-9A-Za-z]+$/ # password
|
120
|
+
|
121
|
+
PAGINATE_PER_PAGE = 20
|
122
|
+
|
123
|
+
DISPLAY_TYPE_SIMPLE = 'simple'
|
124
|
+
|
125
|
+
APP_COMPANY = '#{@app_company}'
|
126
|
+
APP_TITLE = '#{@app_title}'
|
127
|
+
end
|
128
|
+
EOS
|
129
|
+
match.gsub("\nend", s)
|
130
|
+
end
|
131
|
+
|
132
|
+
# development.rb
|
133
|
+
sentinel = "config.cache_classes = false\n\n# Log"
|
134
|
+
m.gsub_file 'config/environments/development.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
135
|
+
s = <<"EOS"
|
136
|
+
|
137
|
+
|
138
|
+
# set log level
|
139
|
+
config.log_level = :debug
|
140
|
+
|
141
|
+
EOS
|
142
|
+
match.gsub("\n\n", s)
|
143
|
+
end
|
144
|
+
|
145
|
+
# session_store.rb
|
146
|
+
sentinel = '# ActionController::Base.session_store = :active_record_store'
|
147
|
+
m.gsub_file 'config/initializers/session_store.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
148
|
+
match.gsub("# ", "")
|
149
|
+
end
|
150
|
+
|
151
|
+
# routes.rb
|
152
|
+
sentinel = "# map.root :controller => \"welcome\"\n\n # See"
|
153
|
+
m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
154
|
+
s = <<'EOS'
|
155
|
+
|
156
|
+
map.root :controller => :auth, :action => :login
|
157
|
+
map.top 'top', :controller => :top, :action => :index
|
158
|
+
|
159
|
+
EOS
|
160
|
+
match.gsub("\n\n", s)
|
161
|
+
end
|
162
|
+
|
163
|
+
sentinel = "map.connect ':controller/:action/:id.:format'\nend"
|
164
|
+
m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
165
|
+
s = <<'EOS'
|
166
|
+
|
167
|
+
map.connect '*path', :controller => :application, :action => :error
|
168
|
+
|
169
|
+
EOS
|
170
|
+
match.gsub("\n", s)
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
protected
|
178
|
+
# Override with your own usage banner.
|
179
|
+
def banner
|
180
|
+
"Usage: #{$0} ava_rails AppName CompanyName"
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_options!(opt)
|
184
|
+
opt.separator ''
|
185
|
+
opt.separator 'Options:'
|
186
|
+
opt.on("--skip-timestamps",
|
187
|
+
"Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
|
188
|
+
opt.on("--skip-migration",
|
189
|
+
"Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
|
190
|
+
opt.on("--force-plural",
|
191
|
+
"Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
|
192
|
+
end
|
193
|
+
|
194
|
+
# def scaffold_views
|
195
|
+
# %w[ index show new edit check confirm ]
|
196
|
+
# end
|
197
|
+
|
198
|
+
# def model_name
|
199
|
+
# class_name.demodulize
|
200
|
+
# end
|
201
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSessions < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :sessions do |t|
|
4
|
+
t.string :session_id, :null => false
|
5
|
+
t.text :data
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :sessions, :session_id
|
10
|
+
add_index :sessions, :updated_at
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :sessions
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
class User < ActiveRecord::Base; end
|
3
|
+
|
4
|
+
def self.up
|
5
|
+
create_table :users do |t|
|
6
|
+
t.string :account
|
7
|
+
t.string :name
|
8
|
+
t.string :hashed_password
|
9
|
+
t.string :salt
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :users, :account, :unique => true
|
13
|
+
|
14
|
+
User.create(:account => 'test', :name => '[Built-in]Masaki Ozawa')
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :users
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
module FormHelper
|
4
|
+
def label_with_ja(object_name, method, text = nil, options = {})
|
5
|
+
if text.nil?
|
6
|
+
text = I18n.t(method, :default => method, :scope => [:activerecord, :attributes, object_name])
|
7
|
+
text = I18n.t(method, :default => method, :scope => [:activerecord, :attributes, "commons"]) if text.include?("translation missing:")
|
8
|
+
text = I18n.t(method.to_s + "_id", :default => method, :scope => [:activerecord, :attributes, object_name]) if text.include?("translation missing:")
|
9
|
+
end
|
10
|
+
label_without_ja(object_name, method, text, options)
|
11
|
+
end
|
12
|
+
alias_method_chain :label, :ja #:nodoc:
|
13
|
+
end
|
14
|
+
|
15
|
+
module DateHelper
|
16
|
+
def date_select_with_options(object_name, method, options = {}, html_options = {})
|
17
|
+
begin
|
18
|
+
object = self.instance_variable_get("@#{object_name}")
|
19
|
+
value = object.send(method)
|
20
|
+
value = I18n.l(value)
|
21
|
+
rescue
|
22
|
+
value = nil
|
23
|
+
end
|
24
|
+
value = "" if value.blank?
|
25
|
+
options.merge!(:class => 'ymd',
|
26
|
+
:size => 14,
|
27
|
+
:maxlength => 10,
|
28
|
+
:readonly => true,
|
29
|
+
:value => value)
|
30
|
+
text_field(object_name, method, options)
|
31
|
+
end
|
32
|
+
alias_method_chain :date_select, :options #:nodoc:
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
ja:
|
2
|
+
number:
|
3
|
+
# Used in number_with_delimiter()
|
4
|
+
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
|
5
|
+
format:
|
6
|
+
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
|
7
|
+
separator: "."
|
8
|
+
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
|
9
|
+
delimiter: ","
|
10
|
+
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
|
11
|
+
precision: 3
|
12
|
+
|
13
|
+
# Used in number_to_currency()
|
14
|
+
currency:
|
15
|
+
format:
|
16
|
+
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
|
17
|
+
format: "%n%u"
|
18
|
+
unit: "円"
|
19
|
+
# These three are to override number.format and are optional
|
20
|
+
separator: "."
|
21
|
+
delimiter: ","
|
22
|
+
precision: 0
|
23
|
+
|
24
|
+
# Used in number_to_percentage()
|
25
|
+
percentage:
|
26
|
+
format:
|
27
|
+
# These three are to override number.format and are optional
|
28
|
+
# separator:
|
29
|
+
delimiter: ""
|
30
|
+
# precision:
|
31
|
+
|
32
|
+
# Used in number_to_precision()
|
33
|
+
precision:
|
34
|
+
format:
|
35
|
+
# These three are to override number.format and are optional
|
36
|
+
# separator:
|
37
|
+
delimiter: ""
|
38
|
+
# precision:
|
39
|
+
|
40
|
+
# Used in number_to_human_size()
|
41
|
+
human:
|
42
|
+
format:
|
43
|
+
# These three are to override number.format and are optional
|
44
|
+
# separator:
|
45
|
+
delimiter: ""
|
46
|
+
precision: 1
|
47
|
+
storage_units:
|
48
|
+
# Storage units output formatting.
|
49
|
+
# %u is the storage unit, %n is the number (default: 2 MB)
|
50
|
+
format: "%n%u"
|
51
|
+
units:
|
52
|
+
byte: "バイト"
|
53
|
+
kb: "キロバイト"
|
54
|
+
mb: "メガバイト"
|
55
|
+
gb: "ギガバイト"
|
56
|
+
tb: "テラバイト"
|
57
|
+
|
58
|
+
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
|
59
|
+
datetime:
|
60
|
+
distance_in_words:
|
61
|
+
half_a_minute: "30秒前後"
|
62
|
+
less_than_x_seconds:
|
63
|
+
one: "1秒以内"
|
64
|
+
other: "{{count}}秒以内"
|
65
|
+
x_seconds:
|
66
|
+
one: "1秒"
|
67
|
+
other: "{{count}}秒"
|
68
|
+
less_than_x_minutes:
|
69
|
+
one: "1分以内"
|
70
|
+
other: "{{count}}分以内"
|
71
|
+
x_minutes:
|
72
|
+
one: "1分"
|
73
|
+
other: "{{count}}分"
|
74
|
+
about_x_hours:
|
75
|
+
one: "約1時間"
|
76
|
+
other: "約{{count}}時間"
|
77
|
+
x_days:
|
78
|
+
one: "1日"
|
79
|
+
other: "{{count}}日"
|
80
|
+
about_x_months:
|
81
|
+
one: "約1ヶ月"
|
82
|
+
other: "約{{count}}ヶ月"
|
83
|
+
x_months:
|
84
|
+
one: "1ヶ月"
|
85
|
+
other: "{{count}}ヶ月"
|
86
|
+
about_x_years:
|
87
|
+
one: "約{{count}}年"
|
88
|
+
other: "約{{count}}年"
|
89
|
+
over_x_years:
|
90
|
+
one: "{{count}}年以上"
|
91
|
+
other: "{{count}}年以上"
|
92
|
+
prompts:
|
93
|
+
year: "年"
|
94
|
+
month: "月"
|
95
|
+
day: "日"
|
96
|
+
hour: "時"
|
97
|
+
minute: "分"
|
98
|
+
second: "秒"
|
99
|
+
|
100
|
+
activerecord:
|
101
|
+
errors:
|
102
|
+
format:
|
103
|
+
separator: ""
|
104
|
+
template:
|
105
|
+
header:
|
106
|
+
one: "{{model}}にエラーが発生しました。"
|
107
|
+
other: "{{model}}に{{count}}つのエラーが発生しました。"
|
108
|
+
# The variable :count is also available
|
109
|
+
body: "次の項目を確認してください。"
|
110
|
+
|
111
|
+
support:
|
112
|
+
select:
|
113
|
+
# default value for :prompt => true in FormOptionsHelper
|
114
|
+
prompt: "選択してください。"
|
115
|
+
|