i18n_dashboard 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +80 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/i18n_dashboard/application.js +17 -0
  5. data/app/assets/javascripts/i18n_dashboard/bootstrap.js.coffee +4 -0
  6. data/app/assets/javascripts/i18n_dashboard/translations.js.coffee +20 -0
  7. data/app/assets/stylesheets/i18n_dashboard/application.css +13 -0
  8. data/app/assets/stylesheets/i18n_dashboard/bootstrap_and_overrides.css +7 -0
  9. data/app/assets/stylesheets/i18n_dashboard/translations.css +4 -0
  10. data/app/controllers/i18n_dashboard/application_controller.rb +4 -0
  11. data/app/controllers/i18n_dashboard/translations_controller.rb +21 -0
  12. data/app/helpers/i18n_dashboard/application_helper.rb +18 -0
  13. data/app/helpers/i18n_dashboard/translations_helper.rb +4 -0
  14. data/app/models/i18n_dashboard/translation.rb +44 -0
  15. data/app/views/i18n_dashboard/translations/index.html.haml +51 -0
  16. data/app/views/layouts/i18n_dashboard/application.html.haml +32 -0
  17. data/config/routes.rb +6 -0
  18. data/lib/assets/javascripts/jquery.autosize.js +192 -0
  19. data/lib/i18n_dashboard.rb +7 -0
  20. data/lib/i18n_dashboard/engine.rb +51 -0
  21. data/lib/i18n_dashboard/version.rb +3 -0
  22. data/lib/tasks/i18n_dashboard_tasks.rake +4 -0
  23. data/test/dummy/README.rdoc +261 -0
  24. data/test/dummy/Rakefile +7 -0
  25. data/test/dummy/app/assets/images/favicon.ico +0 -0
  26. data/test/dummy/app/assets/javascripts/application.js +15 -0
  27. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  28. data/test/dummy/app/controllers/application_controller.rb +3 -0
  29. data/test/dummy/app/helpers/application_helper.rb +2 -0
  30. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/test/dummy/config.ru +4 -0
  32. data/test/dummy/config/application.rb +60 -0
  33. data/test/dummy/config/boot.rb +10 -0
  34. data/test/dummy/config/database.yml +24 -0
  35. data/test/dummy/config/environment.rb +6 -0
  36. data/test/dummy/config/environments/development.rb +37 -0
  37. data/test/dummy/config/environments/production.rb +67 -0
  38. data/test/dummy/config/environments/test.rb +37 -0
  39. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  40. data/test/dummy/config/initializers/inflections.rb +15 -0
  41. data/test/dummy/config/initializers/mime_types.rb +5 -0
  42. data/test/dummy/config/initializers/secret_token.rb +7 -0
  43. data/test/dummy/config/initializers/session_store.rb +8 -0
  44. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/test/dummy/config/locales/en.yml +5 -0
  46. data/test/dummy/config/routes.rb +4 -0
  47. data/test/dummy/db/development.sqlite3 +0 -0
  48. data/test/dummy/db/test.sqlite3 +0 -0
  49. data/test/dummy/log/development.log +14335 -0
  50. data/test/dummy/log/test.log +420 -0
  51. data/test/dummy/public/404.html +26 -0
  52. data/test/dummy/public/422.html +26 -0
  53. data/test/dummy/public/500.html +25 -0
  54. data/test/dummy/public/favicon.ico +0 -0
  55. data/test/dummy/script/rails +6 -0
  56. data/test/dummy/tmp/cache/assets/C17/E40/sprockets%2F4308b5901b3134f6b1541f8a69276431 +0 -0
  57. data/test/dummy/tmp/cache/assets/C27/B00/sprockets%2F1b3e7717131812885279d16959cad225 +0 -0
  58. data/test/dummy/tmp/cache/assets/C29/8A0/sprockets%2Fa899e19256a0845205636938010c6fe5 +0 -0
  59. data/test/dummy/tmp/cache/assets/C57/880/sprockets%2F7610404e10c842a8cb69d7741678e619 +0 -0
  60. data/test/dummy/tmp/cache/assets/C7A/CA0/sprockets%2Fe62364e35231a761b76b13037f954c2f +0 -0
  61. data/test/dummy/tmp/cache/assets/C87/3F0/sprockets%2F1b04f197ed371938f027965191b01ff8 +0 -0
  62. data/test/dummy/tmp/cache/assets/C88/5F0/sprockets%2F69589b2e73a9d05247a6744a00b9d086 +0 -0
  63. data/test/dummy/tmp/cache/assets/C8C/9A0/sprockets%2F61288a069b85281ec267a04d9865cf26 +0 -0
  64. data/test/dummy/tmp/cache/assets/C98/FD0/sprockets%2F0b08d527a505c32173844d01cbc8353b +0 -0
  65. data/test/dummy/tmp/cache/assets/CA0/550/sprockets%2F36f109f19a5f50760020a2350aee6b76 +0 -0
  66. data/test/dummy/tmp/cache/assets/CA2/670/sprockets%2Fde3f90c262d351a812781a381174c0e4 +0 -0
  67. data/test/dummy/tmp/cache/assets/CA2/790/sprockets%2Fa91323b76385b2492b331611cf3a1ee8 +0 -0
  68. data/test/dummy/tmp/cache/assets/CA7/C90/sprockets%2F1e61531b0c665288f42cd0e490de4362 +0 -0
  69. data/test/dummy/tmp/cache/assets/CAB/B40/sprockets%2Fdf24253c225938243de61f4b8e45b350 +0 -0
  70. data/test/dummy/tmp/cache/assets/CB2/880/sprockets%2Fdf63ab7177a704396db76e501e950065 +0 -0
  71. data/test/dummy/tmp/cache/assets/CB3/530/sprockets%2F33561d49d5d2e8b94325b5c34f056f70 +0 -0
  72. data/test/dummy/tmp/cache/assets/CB3/CE0/sprockets%2F061634a9f7e57e6a32b2163094cdf675 +0 -0
  73. data/test/dummy/tmp/cache/assets/CB7/BF0/sprockets%2F88d248598b413e816ecc4a301d702c89 +0 -0
  74. data/test/dummy/tmp/cache/assets/CC4/5E0/sprockets%2Fb4fb33ba57d762df1313232c20172c16 +0 -0
  75. data/test/dummy/tmp/cache/assets/CCF/160/sprockets%2F2a21280366fbd1b4b3b27f8b5b391175 +0 -0
  76. data/test/dummy/tmp/cache/assets/CD6/C30/sprockets%2F68a84eca6a0b8a025698c5a4f1553113 +0 -0
  77. data/test/dummy/tmp/cache/assets/CD7/690/sprockets%2F324f37142a49a78eb59c69dc043221ba +0 -0
  78. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  79. data/test/dummy/tmp/cache/assets/CDA/4A0/sprockets%2Fa4de2f6e912b73e5465154c91360d2b4 +0 -0
  80. data/test/dummy/tmp/cache/assets/CDB/530/sprockets%2F065cdf3144ff76d3672a96b1c4b04534 +0 -0
  81. data/test/dummy/tmp/cache/assets/CDB/FE0/sprockets%2F40ead92d2446ed8d412cc6185222791e +0 -0
  82. data/test/dummy/tmp/cache/assets/CDC/1E0/sprockets%2F794ffe755fdbc072f65081d71400b132 +0 -0
  83. data/test/dummy/tmp/cache/assets/CDE/CB0/sprockets%2Fd0d9c1b1b5416f7830ff460128f267b8 +0 -0
  84. data/test/dummy/tmp/cache/assets/CDF/E80/sprockets%2F13e20c9963f428d80d010b7fd6916a6e +0 -0
  85. data/test/dummy/tmp/cache/assets/CE2/070/sprockets%2Fb88b47b5b7145e2d4a09586357a0d48a +0 -0
  86. data/test/dummy/tmp/cache/assets/CE3/290/sprockets%2F8140ecc79e862a4e363353a1f505f7c7 +0 -0
  87. data/test/dummy/tmp/cache/assets/CE3/910/sprockets%2F0f69e891e76f603460bb2d4be73754a0 +0 -0
  88. data/test/dummy/tmp/cache/assets/D04/A50/sprockets%2F9a5702b9d21b6b356fd1245a532eac48 +0 -0
  89. data/test/dummy/tmp/cache/assets/D09/490/sprockets%2Fa45021c6df1675785caf177e3a33b6f0 +0 -0
  90. data/test/dummy/tmp/cache/assets/D0A/9D0/sprockets%2Fe026d4c914a79065f1bdb1443c52e9e4 +0 -0
  91. data/test/dummy/tmp/cache/assets/D0E/220/sprockets%2F74dd8ae13eb4fd2039d80f63379710a3 +0 -0
  92. data/test/dummy/tmp/cache/assets/D12/340/sprockets%2F9c4299f1befb5b336eee0021648720e7 +0 -0
  93. data/test/dummy/tmp/cache/assets/D14/DF0/sprockets%2Fdc7d2699f906aa73df210a647b906f32 +0 -0
  94. data/test/dummy/tmp/cache/assets/D17/4C0/sprockets%2F700827acd727b6fc8361f454c68a5cd7 +0 -0
  95. data/test/dummy/tmp/cache/assets/D19/4B0/sprockets%2F81b5e5d4982b62a61608083ffd8aa9f4 +0 -0
  96. data/test/dummy/tmp/cache/assets/D1A/960/sprockets%2F5f29e96153e76650daf023ef6eb60c85 +0 -0
  97. data/test/dummy/tmp/cache/assets/D20/A40/sprockets%2Fa8a7dde52a9693a9c76c4521b659717e +0 -0
  98. data/test/dummy/tmp/cache/assets/D23/130/sprockets%2Fd23bf67170bd556698cf57dc98d74a43 +0 -0
  99. data/test/dummy/tmp/cache/assets/D27/B40/sprockets%2Fdeed00121b4375a3b720cef0d19825b4 +0 -0
  100. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  101. data/test/dummy/tmp/cache/assets/D34/650/sprockets%2F506eb0870b70db1817ad51fa7e826fb1 +0 -0
  102. data/test/dummy/tmp/cache/assets/D35/130/sprockets%2F02d1845ddb029d6e52168ecd80bb443d +0 -0
  103. data/test/dummy/tmp/cache/assets/D37/0E0/sprockets%2F7d091415f6d7c0e87302b6cd2fc0d3e3 +0 -0
  104. data/test/dummy/tmp/cache/assets/D38/640/sprockets%2F4a303ec194ba2adad59e674b62666c72 +0 -0
  105. data/test/dummy/tmp/cache/assets/D44/3B0/sprockets%2F7f7402dea766db136ffa0a8e915e3645 +0 -0
  106. data/test/dummy/tmp/cache/assets/D45/900/sprockets%2F4ea0c0d9f777c1c3e6ac2c949c526358 +0 -0
  107. data/test/dummy/tmp/cache/assets/D47/AE0/sprockets%2Fda6c6f8491d0926e5bd66c99e1a4c502 +0 -0
  108. data/test/dummy/tmp/cache/assets/D4C/8F0/sprockets%2F91c3748be4d5d83687d62df1c745b4cb +0 -0
  109. data/test/dummy/tmp/cache/assets/D4D/C80/sprockets%2Fbd91e31998a5390c39c8dfe9e0b2a268 +0 -0
  110. data/test/dummy/tmp/cache/assets/D4E/010/sprockets%2F503bf76de6b580b6084697a0bce9ff94 +0 -0
  111. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  112. data/test/dummy/tmp/cache/assets/D52/510/sprockets%2Fafa6f0e91783285a62239f19abd9e88f +0 -0
  113. data/test/dummy/tmp/cache/assets/D52/660/sprockets%2Fbd777ea944a4e6eac534918e3486dc66 +0 -0
  114. data/test/dummy/tmp/cache/assets/D53/1C0/sprockets%2F5f2c389e5a57cf95066e26bf39c29d5a +0 -0
  115. data/test/dummy/tmp/cache/assets/D54/690/sprockets%2F2e04d9409cb8227f7f85ef58c59fa0e6 +0 -0
  116. data/test/dummy/tmp/cache/assets/D59/0F0/sprockets%2F4270ea9dbd84ff48e02ba315a0ab7230 +0 -0
  117. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  118. data/test/dummy/tmp/cache/assets/D5E/D60/sprockets%2Fa16542dae11a0c28f64da023d98e7bc5 +0 -0
  119. data/test/dummy/tmp/cache/assets/D66/1D0/sprockets%2F126f2983156b26d20a9dece1fe2cca54 +0 -0
  120. data/test/dummy/tmp/cache/assets/D67/550/sprockets%2F325bfe833d0bef2dbc4d4116992c272d +0 -0
  121. data/test/dummy/tmp/cache/assets/D6B/A30/sprockets%2F4953faaf0994fdf44c268a2d3a2e34a1 +0 -0
  122. data/test/dummy/tmp/cache/assets/D6C/730/sprockets%2F8a4c656c6d8f2d130805564fbf0decb2 +0 -0
  123. data/test/dummy/tmp/cache/assets/D6D/3A0/sprockets%2F5072c9166eb56e59594fd1cdcaa0a81b +0 -0
  124. data/test/dummy/tmp/cache/assets/D6D/860/sprockets%2F13bcde6be1a8a4a0699a69a12c9f3944 +0 -0
  125. data/test/dummy/tmp/cache/assets/D70/B60/sprockets%2F0e4af1c70210cea20082a802eb4cba0e +0 -0
  126. data/test/dummy/tmp/cache/assets/D74/170/sprockets%2Fa202c9cbd617a6e5a8522ee738f8da59 +0 -0
  127. data/test/dummy/tmp/cache/assets/D81/650/sprockets%2Fbf62048d8e17fec958bfc40f4f9337f1 +0 -0
  128. data/test/dummy/tmp/cache/assets/D86/550/sprockets%2Fe37f7c1b22f998df87811f6e19df1e5a +0 -0
  129. data/test/dummy/tmp/cache/assets/D89/610/sprockets%2Fc413e3b81dc0aaca2de9b91e8146320e +0 -0
  130. data/test/dummy/tmp/cache/assets/D8E/930/sprockets%2F3eefd876c4c21f796f2875ca958dd63f +0 -0
  131. data/test/dummy/tmp/cache/assets/D8F/350/sprockets%2Fa2f17c30139a4611cf50cbbeed328e9d +0 -0
  132. data/test/dummy/tmp/cache/assets/D9B/3B0/sprockets%2Fe136169a133e4e357fe0fdca6b27bdd7 +0 -0
  133. data/test/dummy/tmp/cache/assets/DA0/C20/sprockets%2F29563dbecedcba0e44f34d6f135769c2 +0 -0
  134. data/test/dummy/tmp/cache/assets/DA3/160/sprockets%2Fd553d92fe1ffa3e59eaebc7c10600797 +0 -0
  135. data/test/dummy/tmp/cache/assets/DA7/A80/sprockets%2Fccfbd170e39dfb846de914e97036b64a +0 -0
  136. data/test/dummy/tmp/cache/assets/DAA/DA0/sprockets%2Ff94eca2ba5f45236fc224fef7f25c579 +0 -0
  137. data/test/dummy/tmp/cache/assets/DAE/2F0/sprockets%2F5bf09d27baa4bbd128e151a2d0fa60a3 +0 -0
  138. data/test/dummy/tmp/cache/assets/DAE/E10/sprockets%2F0cd4f3341cb9a98f2d9d53d4ffc96f90 +0 -0
  139. data/test/dummy/tmp/cache/assets/DB7/310/sprockets%2F1fbb9e98965bbf2ac579e2b31dd8f894 +0 -0
  140. data/test/dummy/tmp/cache/assets/DBD/790/sprockets%2Fe83ef87fc9a96e7df0ea82d5f7542e09 +0 -0
  141. data/test/dummy/tmp/cache/assets/DC4/310/sprockets%2Fce37cfc9e43c166c4f6e0a426602acca +0 -0
  142. data/test/dummy/tmp/cache/assets/DC8/410/sprockets%2Fbce5aec46efaa4562dd4397cd6c26113 +0 -0
  143. data/test/dummy/tmp/cache/assets/DD1/1D0/sprockets%2F3ba28ff187fc1853310effb2ffc77be2 +0 -0
  144. data/test/dummy/tmp/cache/assets/DD7/DC0/sprockets%2F94f1451efc5534b6e18becb9ff751aed +0 -0
  145. data/test/dummy/tmp/cache/assets/DDB/660/sprockets%2F4f4d7807fefc271ae9681d46cbfa7d3c +0 -0
  146. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  147. data/test/dummy/tmp/cache/assets/DDC/780/sprockets%2F6cdaf95075508fdf1d6f9caed58bc912 +0 -0
  148. data/test/dummy/tmp/cache/assets/DDC/AF0/sprockets%2Fc930d4549ca9885a8fec4ebb7b64bec4 +0 -0
  149. data/test/dummy/tmp/cache/assets/DE3/1E0/sprockets%2F585396ba7ec073f6dfbfb617e9c6ae7e +0 -0
  150. data/test/dummy/tmp/cache/assets/DE6/600/sprockets%2F9cc3fd4df486f860e8d7ddf3645c0ef4 +0 -0
  151. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  152. data/test/dummy/tmp/cache/assets/E10/1F0/sprockets%2F9fe678546e13bdced97f0143fdca7efc +0 -0
  153. data/test/dummy/tmp/cache/assets/E4D/ED0/sprockets%2Faf66ce6d0cda4622cc0ddeabf0950ca8 +0 -0
  154. data/test/dummy/tmp/cache/assets/E53/920/sprockets%2Fb53cddcfb4c8ce49c1e0610f4b0be9be +0 -0
  155. data/test/dummy/tmp/cache/assets/E87/E70/sprockets%2Fa441ed46c0f3abe7f8f6dc0b3ad8ecce +0 -0
  156. data/test/functional/i18n_dashboard/translations_controller_test.rb +9 -0
  157. data/test/i18n_dashboard_test.rb +7 -0
  158. data/test/test_helper.rb +18 -0
  159. data/test/unit/helpers/i18n_dashboard/translations_helper_test.rb +6 -0
  160. data/test/unit/i18n_dashboard/translation_test.rb +75 -0
  161. metadata +491 -0
@@ -0,0 +1,7 @@
1
+ require "redis"
2
+ require 'haml'
3
+ require 'twitter-bootstrap-rails'
4
+ require "i18n_dashboard/engine"
5
+
6
+ module I18nDashboard
7
+ end
@@ -0,0 +1,51 @@
1
+ module I18nDashboard
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace I18nDashboard
4
+
5
+
6
+ cattr_accessor :redis
7
+ @@redis = Redis.new
8
+
9
+ class << self
10
+ def load!
11
+ I18n.t('hello')
12
+ translations = I18n.backend.send(:translations)
13
+ keys = extract_i18n_keys(translations)
14
+
15
+
16
+ Engine.redis.del('system_keys')
17
+ to_resave = {}
18
+ keys.each do |full_key|
19
+ key = full_key.split('.')[1..-1].join('.')
20
+ locale = full_key.split('.')[0]
21
+ Engine.redis.sadd('system_keys', key)
22
+
23
+ to_resave[full_key] = I18n.t(key, locale: locale)
24
+ end
25
+
26
+ I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(Engine.redis), I18n.backend)
27
+
28
+ to_resave.each do |full_key, value|
29
+ key = full_key.split('.')[1..-1].join('.')
30
+ locale = full_key.split('.')[0]
31
+ I18n.backend.store_translations(locale, {key => value}, :escape => false)
32
+ end
33
+ end
34
+
35
+ def extract_i18n_keys(hash, parent_keys = [])
36
+ hash.inject([]) do |keys, (key, value)|
37
+ full_key = parent_keys + [key]
38
+ if value.is_a?(Hash)
39
+ # Nested hash
40
+ keys += extract_i18n_keys(value, full_key)
41
+ elsif value.present?
42
+ # String leaf node
43
+ keys << full_key.join(".")
44
+ end
45
+ keys
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module I18nDashboard
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :i18n_dashboard do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,261 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.all
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.org/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- assets
160
+ | | |-- images
161
+ | | |-- javascripts
162
+ | | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | |-- assets
177
+ | `-- tasks
178
+ |-- log
179
+ |-- public
180
+ |-- script
181
+ |-- test
182
+ | |-- fixtures
183
+ | |-- functional
184
+ | |-- integration
185
+ | |-- performance
186
+ | `-- unit
187
+ |-- tmp
188
+ | `-- cache
189
+ | `-- assets
190
+ `-- vendor
191
+ |-- assets
192
+ | |-- javascripts
193
+ | `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
File without changes
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,60 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "i18n_dashboard"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+ config.i18n.available_locales = [:es, :en, :de]
38
+
39
+ # Enable escaping HTML in JSON.
40
+ config.active_support.escape_html_entities_in_json = true
41
+
42
+ # Use SQL instead of Active Record's schema dumper when creating the database.
43
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
44
+ # like if you have constraints or database-specific column types
45
+ # config.active_record.schema_format = :sql
46
+
47
+ # Enforce whitelist mode for mass assignment.
48
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
49
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
50
+ # parameters by using an attr_accessible or attr_protected declaration.
51
+ config.active_record.whitelist_attributes = true
52
+
53
+ # Enable the asset pipeline
54
+ config.assets.enabled = true
55
+
56
+ # Version of your assets, change this if you want to expire all your assets
57
+ config.assets.version = '1.0'
58
+ end
59
+ end
60
+