we_bridge_rails_engine_nations 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +34 -0
  7. data/Gemfile.lock +254 -0
  8. data/LICENSE.txt +21 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +41 -0
  11. data/Rakefile +37 -0
  12. data/app/assets/javascripts/areas.js +2 -0
  13. data/app/assets/javascripts/currencies.js +2 -0
  14. data/app/assets/javascripts/nations.js +2 -0
  15. data/app/assets/javascripts/regions.js +2 -0
  16. data/app/assets/stylesheets/areas.css +4 -0
  17. data/app/assets/stylesheets/currencies.css +4 -0
  18. data/app/assets/stylesheets/nations.css +4 -0
  19. data/app/assets/stylesheets/regions.css +4 -0
  20. data/app/assets/stylesheets/scaffold.css +56 -0
  21. data/app/controllers/areas_controller.rb +7 -0
  22. data/app/controllers/currencies_controller.rb +58 -0
  23. data/app/controllers/nations_controller.rb +7 -0
  24. data/app/controllers/regions_controller.rb +7 -0
  25. data/app/helpers/areas_helper.rb +2 -0
  26. data/app/helpers/currencies_helper.rb +2 -0
  27. data/app/helpers/nations_helper.rb +2 -0
  28. data/app/helpers/regions_helper.rb +2 -0
  29. data/app/mailers/.keep +0 -0
  30. data/app/models/.keep +0 -0
  31. data/app/models/area.rb +14 -0
  32. data/app/models/area_text.rb +7 -0
  33. data/app/models/currency.rb +26 -0
  34. data/app/models/currency_nation_map.rb +4 -0
  35. data/app/models/currency_text.rb +7 -0
  36. data/app/models/nation.rb +45 -0
  37. data/app/models/nation_text.rb +7 -0
  38. data/app/models/region.rb +15 -0
  39. data/app/models/region_text.rb +7 -0
  40. data/app/views/.keep +0 -0
  41. data/app/views/areas/edit.html.builder +1 -0
  42. data/app/views/areas/index.html.builder +1 -0
  43. data/app/views/areas/new.html.builder +1 -0
  44. data/app/views/areas/show.html.builder +1 -0
  45. data/app/views/currencies/_form.html.builder +14 -0
  46. data/app/views/currencies/edit.html.builder +7 -0
  47. data/app/views/currencies/index.html.builder +25 -0
  48. data/app/views/currencies/new.html.builder +5 -0
  49. data/app/views/currencies/show.html.builder +8 -0
  50. data/app/views/nations/edit.html.builder +1 -0
  51. data/app/views/nations/index.html.builder +1 -0
  52. data/app/views/nations/new.html.builder +1 -0
  53. data/app/views/nations/show.html.builder +1 -0
  54. data/app/views/regions/edit.html.builder +1 -0
  55. data/app/views/regions/index.html.builder +1 -0
  56. data/app/views/regions/new.html.builder +1 -0
  57. data/app/views/regions/show.html.builder +1 -0
  58. data/bin/console +14 -0
  59. data/bin/rails +12 -0
  60. data/bin/setup +7 -0
  61. data/config/routes.rb +6 -0
  62. data/db/migrate/20151127040229_create_nations.rb +27 -0
  63. data/db/migrate/20151127040410_create_regions.rb +19 -0
  64. data/db/migrate/20151127040435_create_areas.rb +19 -0
  65. data/db/migrate/20151202041711_create_currencies.rb +28 -0
  66. data/db/seeds.rb +439 -0
  67. data/lib/tasks/we_bridge_rails_engine_nations_tasks.rake +4 -0
  68. data/lib/we_bridge_rails_engine_nations.rb +7 -0
  69. data/lib/we_bridge_rails_engine_nations/engine.rb +24 -0
  70. data/lib/we_bridge_rails_engine_nations/version.rb +3 -0
  71. data/spec/controllers/areas_controller_spec.rb +169 -0
  72. data/spec/controllers/currencies_controller_spec.rb +159 -0
  73. data/spec/controllers/nations_controller_spec.rb +169 -0
  74. data/spec/controllers/regions_controller_spec.rb +169 -0
  75. data/spec/dummy/README.rdoc +28 -0
  76. data/spec/dummy/Rakefile +6 -0
  77. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  78. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  79. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  80. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  81. data/spec/dummy/app/views/layouts/application.html.builder +14 -0
  82. data/spec/dummy/bin/bundle +3 -0
  83. data/spec/dummy/bin/rails +4 -0
  84. data/spec/dummy/bin/rake +4 -0
  85. data/spec/dummy/bin/setup +29 -0
  86. data/spec/dummy/config.ru +4 -0
  87. data/spec/dummy/config/application.rb +28 -0
  88. data/spec/dummy/config/boot.rb +5 -0
  89. data/spec/dummy/config/database.yml +25 -0
  90. data/spec/dummy/config/environment.rb +5 -0
  91. data/spec/dummy/config/environments/development.rb +41 -0
  92. data/spec/dummy/config/environments/production.rb +79 -0
  93. data/spec/dummy/config/environments/test.rb +42 -0
  94. data/spec/dummy/config/initializers/assets.rb +11 -0
  95. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  96. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  97. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  98. data/spec/dummy/config/initializers/inflections.rb +16 -0
  99. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  100. data/spec/dummy/config/initializers/provider_settings.rb +2 -0
  101. data/spec/dummy/config/initializers/session_store.rb +3 -0
  102. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  103. data/spec/dummy/config/locales/en.yml +23 -0
  104. data/spec/dummy/config/omniauth.yml +63 -0
  105. data/spec/dummy/config/omniauth.yml.org +63 -0
  106. data/spec/dummy/config/routes.rb +56 -0
  107. data/spec/dummy/config/secrets.yml +22 -0
  108. data/spec/dummy/db/development.sqlite3 +0 -0
  109. data/spec/dummy/db/schema.rb +221 -0
  110. data/spec/dummy/db/test.sqlite3 +0 -0
  111. data/spec/dummy/log/development.log +46295 -0
  112. data/spec/dummy/log/test.log +678 -0
  113. data/spec/dummy/public/404.html +67 -0
  114. data/spec/dummy/public/422.html +67 -0
  115. data/spec/dummy/public/500.html +66 -0
  116. data/spec/dummy/public/favicon.ico +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3qWp1cfMUMB1L1B8w4KCdPJNoktDLzCgZhyGa-eLd0g.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6VfBYgqqzYcjALfLCOpHzv3E06n_zzoM0lDBI4rnsx0.cache +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6vg_COhVhYBSY6arqzRJFOy9-rF95BfYQsFuol_UGuQ.cache +1 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Azqp0lWcLN5Iz5BDrWrNLqHomPvFzn6pENzB3pm95wo.cache +2 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/GYvDs3EBryNSEN-M5uVb3LOFo1oBWq0iDPijDjBVvUs.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/H0uxW1DRyYygsm_fv_sMfVycqsGCazsfNJhSZU81CFY.cache +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/HcVN18DR0_BmshzEZLPjkeVDruXBZ9iXjboBWmO6Ozw.cache +1 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JigkThideDLksj6ZrufTx6bLVyJBmNDbaouRbMbZdIA.cache +2 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/N2BTDMKiaaZ5__Eeqks0aWBzX-5T9Hg0d0015KmSRQo.cache +1 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NrdOdaS5o4trMDBP6UBqLzFsRrmSPy7XJBBtdwktXqk.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bUQg5IzV2hJHu0Ua4jOdDcbaLqfzpRqx6-qq9C23sts.cache +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/boUHvgQlz503FXEZntk5rEF6Z0dNUvT4VOQquML62dQ.cache +1 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/g5LtU2jYJLiGyWluzwkSuH9dRStTuMGHLO-ivn8wCYE.cache +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/gOWNSsYT5GN_cqGVL1MK1faY9XglwixonQVkDk9Pkvk.cache +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/h-W0KoQGAiH7Sn5Y6HjTaVkoEceKV_LeymnmENnyLYQ.cache +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/n5wUjw8Ag9zP7pgTsene8E7Lj3RyWbqUaf2apVdzwc0.cache +2 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nYdpABG_YyXwDqCH1vBNjh0m2AlewuKD9vT92xFu9Qs.cache +1 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nrXgDez-J-7C7rQSEpAiK0Xj5rK37sysOLNYmJIsb_Q.cache +1 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/r_WSE-C4C32WlhZaTBsdC4x3Mf7EQQ93zBA3xOKSw94.cache +1 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/s7AiRxV9LdOVAylAE38RiKCstOIGXxlkhZ15nV8_GfY.cache +2 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/tXQLPTRHFdkPsB5bF6KRKGiUir3uMwdTnxE0na0vmes.cache +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vTbuVbqVUHIvOo23rSZvO1yTT8C-98lLVXe_JG_6Pr8.cache +1 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/x22RvUd8k76gbEMX05JmfJaBplbMc2omvEoreS8eAqg.cache +1 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/xQIYU3iVajL0UcrfbxTB8PIxGMuRDRvRjmq0ve9-s9U.cache +2 -0
  143. data/spec/factories/areas.rb +6 -0
  144. data/spec/factories/currencies.rb +6 -0
  145. data/spec/factories/nations.rb +6 -0
  146. data/spec/factories/regions.rb +6 -0
  147. data/spec/helpers/areas_helper_spec.rb +15 -0
  148. data/spec/helpers/currencies_helper_spec.rb +15 -0
  149. data/spec/helpers/nations_helper_spec.rb +15 -0
  150. data/spec/helpers/regions_helper_spec.rb +15 -0
  151. data/spec/models/area_spec.rb +5 -0
  152. data/spec/models/currency_spec.rb +24 -0
  153. data/spec/models/nation_spec.rb +24 -0
  154. data/spec/models/region_spec.rb +5 -0
  155. data/spec/rails_helper.rb +54 -0
  156. data/spec/routing/areas_routing_spec.rb +39 -0
  157. data/spec/routing/currencies_routing_spec.rb +39 -0
  158. data/spec/routing/nations_routing_spec.rb +39 -0
  159. data/spec/routing/regions_routing_spec.rb +39 -0
  160. data/spec/spec_helper.rb +2 -0
  161. data/spec/views/areas/edit.html.builder_spec.rb +14 -0
  162. data/spec/views/areas/index.html.builder_spec.rb +14 -0
  163. data/spec/views/areas/new.html.builder_spec.rb +14 -0
  164. data/spec/views/areas/show.html.builder_spec.rb +11 -0
  165. data/spec/views/currencies/edit.html.builder_spec.rb +14 -0
  166. data/spec/views/currencies/index.html.builder_spec.rb +14 -0
  167. data/spec/views/currencies/new.html.builder_spec.rb +14 -0
  168. data/spec/views/currencies/show.html.builder_spec.rb +11 -0
  169. data/spec/views/nations/edit.html.builder_spec.rb +14 -0
  170. data/spec/views/nations/index.html.builder_spec.rb +14 -0
  171. data/spec/views/nations/new.html.builder_spec.rb +14 -0
  172. data/spec/views/nations/show.html.builder_spec.rb +11 -0
  173. data/spec/views/regions/edit.html.builder_spec.rb +14 -0
  174. data/spec/views/regions/index.html.builder_spec.rb +14 -0
  175. data/spec/views/regions/new.html.builder_spec.rb +14 -0
  176. data/spec/views/regions/show.html.builder_spec.rb +11 -0
  177. data/spec/we_bridge_rails_engine_nations_spec.rb +7 -0
  178. data/we_bridge_rails_engine_nations.gemspec +42 -0
  179. metadata +482 -0
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,7 @@
1
+ class AreasController < ApplicationController
2
+ include WeBridge::AutoViewHelper::Controller
3
+ set_model Area
4
+ before_action only: [:edit,:update,:destroy] do
5
+ login_required
6
+ end
7
+ end
@@ -0,0 +1,58 @@
1
+ class CurrenciesController < ApplicationController
2
+ before_action :set_currency, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /currencies
5
+ def index
6
+ @currencies = Currency.all
7
+ end
8
+
9
+ # GET /currencies/1
10
+ def show
11
+ end
12
+
13
+ # GET /currencies/new
14
+ def new
15
+ @currency = Currency.new
16
+ end
17
+
18
+ # GET /currencies/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /currencies
23
+ def create
24
+ @currency = Currency.new(currency_params)
25
+
26
+ if @currency.save
27
+ redirect_to @currency, notice: 'Currency was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /currencies/1
34
+ def update
35
+ if @currency.update(currency_params)
36
+ redirect_to @currency, notice: 'Currency was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /currencies/1
43
+ def destroy
44
+ @currency.destroy
45
+ redirect_to currencies_url, notice: 'Currency was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_currency
51
+ @currency = Currency.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def currency_params
56
+ params[:currency]
57
+ end
58
+ end
@@ -0,0 +1,7 @@
1
+ class NationsController < ApplicationController
2
+ include WeBridge::AutoViewHelper::Controller
3
+ set_model Nation
4
+ before_action only: [:edit,:update,:destroy] do
5
+ login_required
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class RegionsController < ApplicationController
2
+ include WeBridge::AutoViewHelper::Controller
3
+ set_model Region
4
+ before_action only: [:edit,:update,:destroy] do
5
+ login_required
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ module AreasHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CurrenciesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module NationsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module RegionsHelper
2
+ end
data/app/mailers/.keep ADDED
File without changes
data/app/models/.keep ADDED
File without changes
@@ -0,0 +1,14 @@
1
+ require 'action_view/helpers/auto_tag_helper/form_info'
2
+ require 'activerecord/mlang'
3
+ class Area < ActiveRecord::Base
4
+ include ActiveRecord::Mlang
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ set_accessible_attrs :name
7
+ validates :name, presence: true
8
+ def __display__
9
+ self.name
10
+ end
11
+ # set_input_options :email, type: :email
12
+ # set_input_options :url, type: :url
13
+ # set_input_options :tel, type: :phone
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'activerecord/mlang'
2
+ require 'action_view/helpers/auto_tag_helper/form_info'
3
+ class AreaText < ActiveRecord::Base
4
+ include ActiveRecord::Mlang::Text
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ set_accessible_attrs :name
7
+ end
@@ -0,0 +1,26 @@
1
+ require 'action_view/helpers/auto_tag_helper/form_info'
2
+ require 'activerecord/mlang'
3
+ class Currency < ActiveRecord::Base
4
+ has_many :currency_nation_maps
5
+ has_many :nations, through: :currency_nation_maps
6
+
7
+ include ActiveRecord::Mlang
8
+ include ActionView::Helpers::AutoTagHelper::FormInfo
9
+ set_accessible_attrs :name, :iso_code
10
+ validates :iso_code, length: { maximum: self.columns_hash['iso_code'].limit }, presence: false
11
+ def __display__
12
+ self.name
13
+ end
14
+
15
+ def self.[](iso_code)
16
+ self.find_by(iso_code: iso_code.to_s.strip)
17
+ end
18
+
19
+ def add_nation(code)
20
+ if nid = Nation[code].try(:id)
21
+ CurrencyNationMap.find_or_create_by(currency_id: self.id, nation_id: nid)
22
+ else
23
+ nil
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ class CurrencyNationMap < ActiveRecord::Base
2
+ belongs_to :nation
3
+ belongs_to :currency
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'activerecord/mlang'
2
+ require 'action_view/helpers/auto_tag_helper/form_info'
3
+ class CurrencyText < ActiveRecord::Base
4
+ include ActiveRecord::Mlang::Text
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ set_accessible_attrs :name
7
+ end
@@ -0,0 +1,45 @@
1
+ require 'action_view/helpers/auto_tag_helper/form_info'
2
+ require 'activerecord/mlang'
3
+ class Nation < ActiveRecord::Base
4
+ has_many :currency_nation_maps
5
+ has_many :currencies, through: :currency_nation_maps
6
+ belongs_to :region
7
+ include ActiveRecord::Mlang
8
+ include ActionView::Helpers::AutoTagHelper::FormInfo
9
+ set_accessible_attrs :region_id, :name, :code_alpha2, :code_alpha3, :code_numeric, :lat, :lon
10
+ validates :name, presence: true
11
+ len2 = self.columns_hash['code_alpha2'].limit
12
+ validates :code_alpha2, length: { maximum: len2 }, presence: false
13
+ len3 = self.columns_hash['code_alpha3'].limit
14
+ validates :code_alpha3, length: { maximum: len3 }, presence: false
15
+
16
+ latlon = {numericality: { less_than_or_equal_to: 180.0, greater_than_or_equal_to: -180.0 }, allow_nil: true}
17
+ validates :lat, latlon
18
+ validates :lon, latlon
19
+
20
+ def __display__
21
+ self.name
22
+ end
23
+
24
+ def self.[](code_or_num)
25
+ col = :code_alpha2
26
+ if code_or_num.kind_of?(Numeric)
27
+ col = :code_numeric
28
+ else
29
+ col = :code_alpha3 if code_or_num.to_s.strip.size == 3
30
+ end
31
+ self.find_by(col => code_or_num)
32
+ end
33
+
34
+ def add_currency(code)
35
+ if cid = Currency[code].try(:id)
36
+ CurrencyNationMap.find_or_create_by(nation_id: self.id, currency_id: cid)
37
+ else
38
+ nil
39
+ end
40
+ end
41
+
42
+ # set_input_options :email, type: :email
43
+ # set_input_options :url, type: :url
44
+ # set_input_options :tel, type: :phone
45
+ end
@@ -0,0 +1,7 @@
1
+ require 'activerecord/mlang'
2
+ require 'action_view/helpers/auto_tag_helper/form_info'
3
+ class NationText < ActiveRecord::Base
4
+ include ActiveRecord::Mlang::Text
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ set_accessible_attrs :name
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'action_view/helpers/auto_tag_helper/form_info'
2
+ require 'activerecord/mlang'
3
+ class Region < ActiveRecord::Base
4
+ belongs_to :area
5
+ include ActiveRecord::Mlang
6
+ include ActionView::Helpers::AutoTagHelper::FormInfo
7
+ set_accessible_attrs :area_id, :name
8
+ validates :name, presence: true
9
+ def __display__
10
+ self.name
11
+ end
12
+ # set_input_options :email, type: :email
13
+ # set_input_options :url, type: :url
14
+ # set_input_options :tel, type: :phone
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'activerecord/mlang'
2
+ require 'action_view/helpers/auto_tag_helper/form_info'
3
+ class RegionText < ActiveRecord::Base
4
+ include ActiveRecord::Mlang::Text
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ set_accessible_attrs :name
7
+ end
data/app/views/.keep ADDED
File without changes
@@ -0,0 +1 @@
1
+ edit_common @record, area_path(id: @record), back_path: areas_path, show_path: area_path(id: @record)
@@ -0,0 +1 @@
1
+ index_common(@records, show_path: ->(record){ area_path(id: record.id)}, edit_path: ->(record){ edit_area_path(record) }, new_path: new_area_path )
@@ -0,0 +1 @@
1
+ new_common(@record, areas_path, back_path: areas_path)
@@ -0,0 +1 @@
1
+ show_common @record, show_path: area_path(id: @record), back_path: areas_path, edit_path: edit_area_path(id: @record)
@@ -0,0 +1,14 @@
1
+ form_for @currency do |f|
2
+ markup{|m|
3
+ if @currency.errors.any?
4
+ #error_explanation
5
+ m.h2 "#{pluralize(@currency.errors.count, "error")} prohibited this currency from being saved:"
6
+ m.ul do
7
+ @currency.errors.full_messages.each do |message|
8
+ m.li message
9
+ end
10
+ end
11
+ end
12
+ m << f.submit
13
+ }.html_safe
14
+ end
@@ -0,0 +1,7 @@
1
+ markup do |m|
2
+ m.h1 "Editing currency"
3
+ m << render('form')
4
+ m << link_to('Show', @currency)
5
+ m << link_to('Back', currencies_path)
6
+ end
7
+
@@ -0,0 +1,25 @@
1
+ markup do |m|
2
+ m.h1 'Listing currencies'
3
+ m.table do
4
+ m.thead do
5
+ m.tr do
6
+ m.th
7
+ m.th
8
+ m.th
9
+ end
10
+ end
11
+ m.tbody do
12
+ @currencies.each do |currency|
13
+ m.tr do
14
+ m.td { m << link_to('Show', 'currency') }
15
+ m.td { m << link_to('Edit', edit_currency_path(currency)) }
16
+ m.td { m << link_to('Destroy', currency, data: { confirm: 'Are you sure?' }, method: :delete) }
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ m.br
23
+ m << link_to('New Currency', new_currency_path)
24
+
25
+ end
@@ -0,0 +1,5 @@
1
+ markup do |m|
2
+ m.h1 'New currency'
3
+ m << render('form')
4
+ m << link_to('Back', currencies_path)
5
+ end
@@ -0,0 +1,8 @@
1
+ markup do |m|
2
+ m.p id: 'notice'
3
+ m.dl do
4
+ end
5
+
6
+ m << link_to('Edit', edit_currency_path(@currency))
7
+ m << link_to('Back', currencies_path)
8
+ end