databaseformalizer 0.3.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 (267) hide show
  1. data/.project +18 -0
  2. data/README +256 -0
  3. data/README.md +2 -0
  4. data/Rakefile +21 -0
  5. data/app/controllers/databaseformalizer/attr_defs_controller.rb +98 -0
  6. data/app/controllers/databaseformalizer/attr_vals_controller.rb +85 -0
  7. data/app/controllers/databaseformalizer/dbformahome_controller.rb +7 -0
  8. data/app/controllers/databaseformalizer/entities_controller.rb +105 -0
  9. data/app/controllers/databaseformalizer/entity_defs_controller.rb +90 -0
  10. data/app/helpers/application_helper.rb +2 -0
  11. data/app/helpers/databaseformalizer/application_helper.rb +4 -0
  12. data/app/helpers/databaseformalizer/attr_defs_helper.rb +4 -0
  13. data/app/helpers/databaseformalizer/attr_vals_helper.rb +4 -0
  14. data/app/helpers/databaseformalizer/dbformahome_helper.rb +4 -0
  15. data/app/helpers/databaseformalizer/entities_helper.rb +160 -0
  16. data/app/helpers/databaseformalizer/entity_defs_helper.rb +68 -0
  17. data/app/models/databaseformalizer/attr_def.rb +48 -0
  18. data/app/models/databaseformalizer/attr_list_join_def.rb +17 -0
  19. data/app/models/databaseformalizer/attr_list_join_val.rb +18 -0
  20. data/app/models/databaseformalizer/attr_val.rb +36 -0
  21. data/app/models/databaseformalizer/attr_vals_entity.rb +18 -0
  22. data/app/models/databaseformalizer/entity.rb +27 -0
  23. data/app/models/databaseformalizer/entity_def.rb +24 -0
  24. data/app/models/databaseformalizer/entity_def_attr_def.rb +18 -0
  25. data/app/views/databaseformalizer/attr_defs/_form.html.erb +74 -0
  26. data/app/views/databaseformalizer/attr_defs/edit.html.erb +7 -0
  27. data/app/views/databaseformalizer/attr_defs/index.html.erb +38 -0
  28. data/app/views/databaseformalizer/attr_defs/new.html.erb +6 -0
  29. data/app/views/databaseformalizer/attr_defs/show.html.erb +50 -0
  30. data/app/views/databaseformalizer/attr_vals/_form.html.erb +29 -0
  31. data/app/views/databaseformalizer/attr_vals/edit.html.erb +7 -0
  32. data/app/views/databaseformalizer/attr_vals/index.html.erb +28 -0
  33. data/app/views/databaseformalizer/attr_vals/new.html.erb +6 -0
  34. data/app/views/databaseformalizer/attr_vals/show.html.erb +20 -0
  35. data/app/views/databaseformalizer/dbformahome/index.html.erb +19 -0
  36. data/app/views/databaseformalizer/entities/_attr_val_boolean_form.html.erb +7 -0
  37. data/app/views/databaseformalizer/entities/_attr_val_checkList_form.html.erb +22 -0
  38. data/app/views/databaseformalizer/entities/_attr_val_datetime_form.html.erb +15 -0
  39. data/app/views/databaseformalizer/entities/_attr_val_entityDef_form.html.erb +14 -0
  40. data/app/views/databaseformalizer/entities/_attr_val_form_all.html.erb +4 -0
  41. data/app/views/databaseformalizer/entities/_attr_val_form_one.html.erb +6 -0
  42. data/app/views/databaseformalizer/entities/_attr_val_integer_form.html.erb +10 -0
  43. data/app/views/databaseformalizer/entities/_attr_val_openList_element_form.html.erb +16 -0
  44. data/app/views/databaseformalizer/entities/_attr_val_openList_form.html.erb +12 -0
  45. data/app/views/databaseformalizer/entities/_attr_val_selectOneInList_form.html.erb +20 -0
  46. data/app/views/databaseformalizer/entities/_attr_val_string_form.html.erb +10 -0
  47. data/app/views/databaseformalizer/entities/_attr_val_text_form.html.erb +10 -0
  48. data/app/views/databaseformalizer/entities/_form.html.erb +54 -0
  49. data/app/views/databaseformalizer/entities/edit.html.erb +8 -0
  50. data/app/views/databaseformalizer/entities/index.html.erb +45 -0
  51. data/app/views/databaseformalizer/entities/new.html.erb +10 -0
  52. data/app/views/databaseformalizer/entities/new.js.erb +1 -0
  53. data/app/views/databaseformalizer/entities/show.html.erb +50 -0
  54. data/app/views/databaseformalizer/entity_defs/_form.html.erb +51 -0
  55. data/app/views/databaseformalizer/entity_defs/edit.html.erb +7 -0
  56. data/app/views/databaseformalizer/entity_defs/index.html.erb +57 -0
  57. data/app/views/databaseformalizer/entity_defs/new.html.erb +6 -0
  58. data/app/views/databaseformalizer/entity_defs/show.html.erb +30 -0
  59. data/app/views/databaseformalizer/layouts/application.html.erb +134 -0
  60. data/databaseformalizer.gemspec +34 -0
  61. data/lib/acts_as_entity/base.rb +101 -0
  62. data/lib/application_controller.rb +21 -0
  63. data/lib/application_helper.rb +3 -0
  64. data/lib/databaseformalizer.rb +27 -0
  65. data/lib/engine.rb +23 -0
  66. data/lib/generators/entity_def/USAGE +8 -0
  67. data/lib/generators/entity_def/entity_def_generator.rb +39 -0
  68. data/lib/generators/entity_def/templates/controller.rb +98 -0
  69. data/lib/generators/entity_def/templates/helper.rb +2 -0
  70. data/lib/generators/entity_def/templates/model.rb +3 -0
  71. data/lib/generators/entity_def/templates/view/_form.html.erb +35 -0
  72. data/lib/generators/entity_def/templates/view/edit.html.erb +6 -0
  73. data/lib/generators/entity_def/templates/view/index.html.erb +27 -0
  74. data/lib/generators/entity_def/templates/view/new.html.erb +5 -0
  75. data/lib/generators/entity_def/templates/view/show.html.erb +3 -0
  76. data/lib/rails/generators/databaseformalizer/databaseformalizer_generator.rb +52 -0
  77. data/lib/rails/generators/databaseformalizer/templates/initializer.rb +8 -0
  78. data/lib/rails/generators/databaseformalizer/templates/migration.rb +9 -0
  79. data/lib/rails/generators/databaseformalizer/templates/migration.rb.bak +9 -0
  80. data/lib/rails/generators/databaseformalizer/templates/schema.rb +84 -0
  81. data/lib/rails/railties/tasks.rake +8 -0
  82. data/public/bootstrap/css/bootstrap-fixed-header.css +15 -0
  83. data/public/bootstrap/css/bootstrap-responsive.css +808 -0
  84. data/public/bootstrap/css/bootstrap-responsive.min.css +9 -0
  85. data/public/bootstrap/css/bootstrap-toggle.css +242 -0
  86. data/public/bootstrap/css/cerulean/bootstrap.min.css +740 -0
  87. data/public/bootstrap/css/img/glyphicons-halflings-white.png +0 -0
  88. data/public/bootstrap/css/img/glyphicons-halflings.png +0 -0
  89. data/public/bootstrap/js/bootstrap-alert.js +90 -0
  90. data/public/bootstrap/js/bootstrap-collapse.js +157 -0
  91. data/public/bootstrap/js/bootstrap-dropdown.js +100 -0
  92. data/public/bootstrap/js/bootstrap-fixed-header.js +54 -0
  93. data/public/bootstrap/js/bootstrap-modal.js +218 -0
  94. data/public/bootstrap/js/bootstrap-popover.js +98 -0
  95. data/public/bootstrap/js/bootstrap-tab.js +135 -0
  96. data/public/bootstrap/js/bootstrap-toggle.js +104 -0
  97. data/public/bootstrap/js/bootstrap-tooltip.js +275 -0
  98. data/public/bootstrap/js/bootstrap-transition.js +61 -0
  99. data/public/bootstrap/js/bootstrap.js +1824 -0
  100. data/public/bootstrap/js/bootstrap.min.js +6 -0
  101. data/public/images/Thumbs.db +0 -0
  102. data/public/images/bootstrap/Thumbs.db +0 -0
  103. data/public/images/bootstrap/glyphicons-halflings.png +0 -0
  104. data/public/images/databaseformalizer.jpg +0 -0
  105. data/public/images/metamodel.png +0 -0
  106. data/public/images/model.png +0 -0
  107. data/public/javascripts/databaseformalizer.js +13 -0
  108. data/public/javascripts/jquery.js +9252 -0
  109. data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  110. data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  111. data/public/jquery-ui/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  112. data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  113. data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  114. data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  115. data/public/jquery-ui/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  116. data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  117. data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  118. data/public/jquery-ui/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  119. data/public/jquery-ui/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  120. data/public/jquery-ui/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  121. data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  122. data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  123. data/public/jquery-ui/css/ui-lightness/jquery-ui-1.8.21.custom.css +565 -0
  124. data/public/jquery-ui/js/jquery-1.7.2.min.js +4 -0
  125. data/public/jquery-ui/js/jquery-ui-1.8.21.custom.min.js +125 -0
  126. data/public/jquery-validation/README.md +8 -0
  127. data/public/jquery-validation/additional-methods.js +300 -0
  128. data/public/jquery-validation/additional-methods.min.js +29 -0
  129. data/public/jquery-validation/changelog.txt +277 -0
  130. data/public/jquery-validation/jquery.validate.js +1188 -0
  131. data/public/jquery-validation/jquery.validate.min.js +51 -0
  132. data/public/jquery-validation/lib/jquery-1.3.2.js +4376 -0
  133. data/public/jquery-validation/lib/jquery-1.4.2.js +6240 -0
  134. data/public/jquery-validation/lib/jquery-1.4.4.js +7179 -0
  135. data/public/jquery-validation/lib/jquery-1.5.2.js +8374 -0
  136. data/public/jquery-validation/lib/jquery-1.6.1.js +8936 -0
  137. data/public/jquery-validation/lib/jquery.form.js +660 -0
  138. data/public/jquery-validation/lib/jquery.js +4376 -0
  139. data/public/jquery-validation/lib/jquery.metadata.js +122 -0
  140. data/public/jquery-validation/lib/jquery.mockjax.js +382 -0
  141. data/public/jquery-validation/localization/messages_ar.js +24 -0
  142. data/public/jquery-validation/localization/messages_bg.js +23 -0
  143. data/public/jquery-validation/localization/messages_ca.js +23 -0
  144. data/public/jquery-validation/localization/messages_cn.js +23 -0
  145. data/public/jquery-validation/localization/messages_cs.js +23 -0
  146. data/public/jquery-validation/localization/messages_da.js +20 -0
  147. data/public/jquery-validation/localization/messages_de.js +20 -0
  148. data/public/jquery-validation/localization/messages_el.js +24 -0
  149. data/public/jquery-validation/localization/messages_es.js +23 -0
  150. data/public/jquery-validation/localization/messages_eu.js +23 -0
  151. data/public/jquery-validation/localization/messages_fa.js +23 -0
  152. data/public/jquery-validation/localization/messages_fi.js +21 -0
  153. data/public/jquery-validation/localization/messages_fr.js +23 -0
  154. data/public/jquery-validation/localization/messages_ge.js +23 -0
  155. data/public/jquery-validation/localization/messages_he.js +23 -0
  156. data/public/jquery-validation/localization/messages_hu.js +20 -0
  157. data/public/jquery-validation/localization/messages_it.js +23 -0
  158. data/public/jquery-validation/localization/messages_ja.js +23 -0
  159. data/public/jquery-validation/localization/messages_kk.js +23 -0
  160. data/public/jquery-validation/localization/messages_lt.js +23 -0
  161. data/public/jquery-validation/localization/messages_lv.js +23 -0
  162. data/public/jquery-validation/localization/messages_nl.js +23 -0
  163. data/public/jquery-validation/localization/messages_no.js +23 -0
  164. data/public/jquery-validation/localization/messages_pl.js +23 -0
  165. data/public/jquery-validation/localization/messages_ptbr.js +23 -0
  166. data/public/jquery-validation/localization/messages_ptpt.js +23 -0
  167. data/public/jquery-validation/localization/messages_ro.js +23 -0
  168. data/public/jquery-validation/localization/messages_ru.js +23 -0
  169. data/public/jquery-validation/localization/messages_se.js +21 -0
  170. data/public/jquery-validation/localization/messages_si.js +23 -0
  171. data/public/jquery-validation/localization/messages_sk.js +20 -0
  172. data/public/jquery-validation/localization/messages_sl.js +23 -0
  173. data/public/jquery-validation/localization/messages_sr.js +23 -0
  174. data/public/jquery-validation/localization/messages_th.js +23 -0
  175. data/public/jquery-validation/localization/messages_tr.js +23 -0
  176. data/public/jquery-validation/localization/messages_tw.js +23 -0
  177. data/public/jquery-validation/localization/messages_ua.js +23 -0
  178. data/public/jquery-validation/localization/messages_vi.js +23 -0
  179. data/public/jquery-validation/localization/methods_de.js +12 -0
  180. data/public/jquery-validation/localization/methods_nl.js +9 -0
  181. data/public/jquery-validation/localization/methods_pt.js +9 -0
  182. data/public/jquery-validation/todo +172 -0
  183. data/public/jquery-validation/version.txt +1 -0
  184. data/public/stylesheets/databaseformalizer.css +64 -0
  185. data/public/stylesheets/scaffold.css +56 -0
  186. data/public/tablesorter/addons/.svn/all-wcprops +5 -0
  187. data/public/tablesorter/addons/.svn/entries +31 -0
  188. data/public/tablesorter/addons/pager/.svn/all-wcprops +17 -0
  189. data/public/tablesorter/addons/pager/.svn/entries +96 -0
  190. data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.css.svn-base +5 -0
  191. data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.js.svn-base +5 -0
  192. data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.css.svn-base +25 -0
  193. data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.js.svn-base +184 -0
  194. data/public/tablesorter/addons/pager/jquery.tablesorter.pager.css +25 -0
  195. data/public/tablesorter/addons/pager/jquery.tablesorter.pager.js +184 -0
  196. data/public/tablesorter/build/.svn/all-wcprops +47 -0
  197. data/public/tablesorter/build/.svn/entries +266 -0
  198. data/public/tablesorter/build/.svn/prop-base/ParseMaster.js.svn-base +5 -0
  199. data/public/tablesorter/build/.svn/prop-base/js.jar.svn-base +5 -0
  200. data/public/tablesorter/build/.svn/prop-base/jsmin.js.svn-base +5 -0
  201. data/public/tablesorter/build/.svn/prop-base/min.js.svn-base +5 -0
  202. data/public/tablesorter/build/.svn/prop-base/pack.js.svn-base +5 -0
  203. data/public/tablesorter/build/.svn/prop-base/packer.js.svn-base +5 -0
  204. data/public/tablesorter/build/.svn/prop-base/writeFile.js.svn-base +5 -0
  205. data/public/tablesorter/build/.svn/text-base/ParseMaster.js.svn-base +106 -0
  206. data/public/tablesorter/build/.svn/text-base/js.jar.svn-base +0 -0
  207. data/public/tablesorter/build/.svn/text-base/jsmin.js.svn-base +316 -0
  208. data/public/tablesorter/build/.svn/text-base/min.js.svn-base +5 -0
  209. data/public/tablesorter/build/.svn/text-base/pack.js.svn-base +5 -0
  210. data/public/tablesorter/build/.svn/text-base/packer.js.svn-base +316 -0
  211. data/public/tablesorter/build/.svn/text-base/writeFile.js.svn-base +19 -0
  212. data/public/tablesorter/build/ParseMaster.js +106 -0
  213. data/public/tablesorter/build/js.jar +0 -0
  214. data/public/tablesorter/build/jsmin.js +316 -0
  215. data/public/tablesorter/build/min.js +5 -0
  216. data/public/tablesorter/build/pack.js +5 -0
  217. data/public/tablesorter/build/packer.js +316 -0
  218. data/public/tablesorter/build/writeFile.js +19 -0
  219. data/public/tablesorter/build.xml +26 -0
  220. data/public/tablesorter/changelog +41 -0
  221. data/public/tablesorter/jquery-latest.js +154 -0
  222. data/public/tablesorter/jquery.metadata.js +122 -0
  223. data/public/tablesorter/jquery.tablesorter.js +1031 -0
  224. data/public/tablesorter/jquery.tablesorter.min.js +4 -0
  225. data/public/tablesorter/jquery.tablesorter.widgets.js +433 -0
  226. data/public/tablesorter/jquery.ui.datepicker.js +1727 -0
  227. data/public/tablesorter/style.css +110 -0
  228. data/public/tablesorter/themes/.svn/all-wcprops +5 -0
  229. data/public/tablesorter/themes/.svn/entries +34 -0
  230. data/public/tablesorter/themes/blue/.svn/all-wcprops +35 -0
  231. data/public/tablesorter/themes/blue/.svn/entries +198 -0
  232. data/public/tablesorter/themes/blue/.svn/prop-base/asc.gif.svn-base +5 -0
  233. data/public/tablesorter/themes/blue/.svn/prop-base/bg.gif.svn-base +5 -0
  234. data/public/tablesorter/themes/blue/.svn/prop-base/blue.zip.svn-base +5 -0
  235. data/public/tablesorter/themes/blue/.svn/prop-base/desc.gif.svn-base +5 -0
  236. data/public/tablesorter/themes/blue/.svn/prop-base/style.css.svn-base +5 -0
  237. data/public/tablesorter/themes/blue/.svn/text-base/asc.gif.svn-base +0 -0
  238. data/public/tablesorter/themes/blue/.svn/text-base/bg.gif.svn-base +0 -0
  239. data/public/tablesorter/themes/blue/.svn/text-base/blue.zip.svn-base +0 -0
  240. data/public/tablesorter/themes/blue/.svn/text-base/desc.gif.svn-base +0 -0
  241. data/public/tablesorter/themes/blue/.svn/text-base/style.css.svn-base +39 -0
  242. data/public/tablesorter/themes/blue/asc.gif +0 -0
  243. data/public/tablesorter/themes/blue/bg.gif +0 -0
  244. data/public/tablesorter/themes/blue/blue.zip +0 -0
  245. data/public/tablesorter/themes/blue/desc.gif +0 -0
  246. data/public/tablesorter/themes/blue/style.css +39 -0
  247. data/public/tablesorter/themes/green/.svn/all-wcprops +35 -0
  248. data/public/tablesorter/themes/green/.svn/entries +198 -0
  249. data/public/tablesorter/themes/green/.svn/prop-base/asc.png.svn-base +5 -0
  250. data/public/tablesorter/themes/green/.svn/prop-base/bg.png.svn-base +5 -0
  251. data/public/tablesorter/themes/green/.svn/prop-base/desc.png.svn-base +5 -0
  252. data/public/tablesorter/themes/green/.svn/prop-base/green.zip.svn-base +5 -0
  253. data/public/tablesorter/themes/green/.svn/prop-base/style.css.svn-base +5 -0
  254. data/public/tablesorter/themes/green/.svn/text-base/asc.png.svn-base +0 -0
  255. data/public/tablesorter/themes/green/.svn/text-base/bg.png.svn-base +0 -0
  256. data/public/tablesorter/themes/green/.svn/text-base/desc.png.svn-base +0 -0
  257. data/public/tablesorter/themes/green/.svn/text-base/green.zip.svn-base +0 -0
  258. data/public/tablesorter/themes/green/.svn/text-base/style.css.svn-base +39 -0
  259. data/public/tablesorter/themes/green/asc.png +0 -0
  260. data/public/tablesorter/themes/green/bg.png +0 -0
  261. data/public/tablesorter/themes/green/desc.png +0 -0
  262. data/public/tablesorter/themes/green/green.zip +0 -0
  263. data/public/tablesorter/themes/green/style.css +39 -0
  264. data/test/database.yml +5 -0
  265. data/test/test_helper.rb +56 -0
  266. data/test/unit/databaseformalizer_test.rb +11 -0
  267. metadata +332 -0
data/.project ADDED
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>databaseformalizer</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.aptana.ide.core.unifiedBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.radrails.rails.core.railsnature</nature>
16
+ <nature>com.aptana.ruby.core.rubynature</nature>
17
+ </natures>
18
+ </projectDescription>
data/README ADDED
@@ -0,0 +1,256 @@
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.find(: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.com/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
+ | |-- controllers
160
+ | |-- helpers
161
+ | |-- mailers
162
+ | |-- models
163
+ | `-- views
164
+ | `-- layouts
165
+ |-- config
166
+ | |-- environments
167
+ | |-- initializers
168
+ | `-- locales
169
+ |-- db
170
+ |-- doc
171
+ |-- lib
172
+ | `-- tasks
173
+ |-- log
174
+ |-- public
175
+ | |-- images
176
+ | |-- javascripts
177
+ | `-- stylesheets
178
+ |-- script
179
+ |-- test
180
+ | |-- fixtures
181
+ | |-- functional
182
+ | |-- integration
183
+ | |-- performance
184
+ | `-- unit
185
+ |-- tmp
186
+ | |-- cache
187
+ | |-- pids
188
+ | |-- sessions
189
+ | `-- sockets
190
+ `-- vendor
191
+ `-- plugins
192
+
193
+ app
194
+ Holds all the code that's specific to this particular application.
195
+
196
+ app/controllers
197
+ Holds controllers that should be named like weblogs_controller.rb for
198
+ automated URL mapping. All controllers should descend from
199
+ ApplicationController which itself descends from ActionController::Base.
200
+
201
+ app/models
202
+ Holds models that should be named like post.rb. Models descend from
203
+ ActiveRecord::Base by default.
204
+
205
+ app/views
206
+ Holds the template files for the view that should be named like
207
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
208
+ eRuby syntax by default.
209
+
210
+ app/views/layouts
211
+ Holds the template files for layouts to be used with views. This models the
212
+ common header/footer method of wrapping views. In your views, define a layout
213
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
214
+ Inside default.html.erb, call <% yield %> to render the view using this
215
+ layout.
216
+
217
+ app/helpers
218
+ Holds view helpers that should be named like weblogs_helper.rb. These are
219
+ generated for you automatically when using generators for controllers.
220
+ Helpers can be used to wrap functionality for your views into methods.
221
+
222
+ config
223
+ Configuration files for the Rails environment, the routing map, the database,
224
+ and other dependencies.
225
+
226
+ db
227
+ Contains the database schema in schema.rb. db/migrate contains all the
228
+ sequence of Migrations for your schema.
229
+
230
+ doc
231
+ This directory is where your application documentation will be stored when
232
+ generated using <tt>rake doc:app</tt>
233
+
234
+ lib
235
+ Application specific libraries. Basically, any kind of custom code that
236
+ doesn't belong under controllers, models, or helpers. This directory is in
237
+ the load path.
238
+
239
+ public
240
+ The directory available for the web server. Contains subdirectories for
241
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
242
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
243
+ server.
244
+
245
+ script
246
+ Helper scripts for automation and generation.
247
+
248
+ test
249
+ Unit and functional tests along with fixtures. When using the rails generate
250
+ command, template test files will be generated for you and placed in this
251
+ directory.
252
+
253
+ vendor
254
+ External libraries that the application depends on. Also includes the plugins
255
+ subdirectory. If the app has frozen rails, those gems also go here, under
256
+ vendor/rails/. This directory is in the load path.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ databaseFormalizer
2
+ ==================
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |test|
4
+ test.pattern = 'test/**/*_test.rb'
5
+ test.libs << 'test'
6
+ end
7
+
8
+
9
+ begin
10
+ require "jeweler"
11
+ Jeweler::Tasks.new do |gem|
12
+ gem.name = "databaseFormalizer"
13
+ gem.summary = "Description of your gem"
14
+ gem.email = "you@email.com"
15
+ gem.authors = ["Your Name"]
16
+ gem.files = Dir["{lib}/**/*", "{app}/**/*", "{public}/**/*", "{config}/**/*"]
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue
20
+ puts "Jeweler or dependency not available."
21
+ end
@@ -0,0 +1,98 @@
1
+ module Databaseformalizer
2
+ class AttrDefsController < ApplicationController
3
+ # GET /attr_defs
4
+ # GET /attr_defs.json
5
+ def index
6
+ @attr_defs = AttrDef.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @attr_defs }
11
+ end
12
+ end
13
+
14
+ # GET /attr_defs/1
15
+ # GET /attr_defs/1.json
16
+ def show
17
+ @attr_def = AttrDef.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render json: @attr_def }
22
+ end
23
+ end
24
+
25
+ # GET /attr_defs/new
26
+ # GET /attr_defs/new.json
27
+ def new
28
+ @attr_def = AttrDef.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @attr_def }
33
+ end
34
+ end
35
+
36
+ # GET /attr_defs/1/edit
37
+ def edit
38
+ @attr_def = AttrDef.find(params[:id])
39
+ end
40
+
41
+ # POST /attr_defs
42
+ # POST /attr_defs.json
43
+ def create
44
+ @attr_def = AttrDef.new(params[:databaseformalizer_attr_def])
45
+ if @attr_def.label == ""
46
+ @attr_def.label = @attr_def.attr_def_name
47
+ end
48
+
49
+ if params[:databaseformalizer_attr_def]['dataType'] == "entityDef"
50
+ @attr_def.child_entity_def_name=params[:databaseformalizer_attr_def]['child_entity_def_name']
51
+ else
52
+ @attr_def.child_entity_def_name=nil
53
+ end
54
+
55
+ respond_to do |format|
56
+ if @attr_def.save
57
+ format.html { redirect_to @attr_def, notice: 'Attr def was successfully created.' }
58
+ format.json { render json: @attr_def, status: :created, location: @attr_def }
59
+ else
60
+ format.html { render action: "new" }
61
+ format.json { render json: @attr_def.errors, status: :unprocessable_entity }
62
+ end
63
+ end
64
+ end
65
+
66
+ # PUT /attr_defs/1
67
+ # PUT /attr_defs/1.json
68
+ def update
69
+ @attr_def = AttrDef.find(params[:id])
70
+ if params[:databaseformalizer_attr_def]['dataType'] == "entityDef"
71
+ @attr_def.child_entity_def_name=params[:databaseformalizer_attr_def]['child_entity_def_name']
72
+ else
73
+ @attr_def.child_entity_def_name=nil
74
+ end
75
+ respond_to do |format|
76
+ if @attr_def.update_attributes(params[:databaseformalizer_attr_def])
77
+ format.html { redirect_to @attr_def, notice: 'Attr def was successfully updated.'}
78
+ format.json { head :no_content }
79
+ else
80
+ format.html { render action: "edit" }
81
+ format.json { render json: @attr_def.errors, status: :unprocessable_entity }
82
+ end
83
+ end
84
+ end
85
+
86
+ # DELETE /attr_defs/1
87
+ # DELETE /attr_defs/1.json
88
+ def destroy
89
+ @attr_def = AttrDef.find(params[:id])
90
+ @attr_def.destroy
91
+
92
+ respond_to do |format|
93
+ format.html { redirect_to databaseformalizer_attr_defs_url }
94
+ format.json { head :no_content }
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,85 @@
1
+ module Databaseformalizer
2
+ class AttrValsController < ApplicationController
3
+ # GET /attr_vals
4
+ # GET /attr_vals.json
5
+ def index
6
+ @attr_vals = AttrVal.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @attr_vals }
11
+ end
12
+ end
13
+
14
+ # GET /attr_vals/1
15
+ # GET /attr_vals/1.json
16
+ def show
17
+ @attr_val = AttrVal.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render json: @attr_val }
22
+ end
23
+ end
24
+
25
+ # GET /attr_vals/new
26
+ # GET /attr_vals/new.json
27
+ def new
28
+ @attr_val = AttrVal.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @attr_val }
33
+ end
34
+ end
35
+
36
+ # GET /attr_vals/1/edit
37
+ def edit
38
+ @attr_val = AttrVal.find(params[:id])
39
+ end
40
+
41
+ # POST /attr_vals
42
+ # POST /attr_vals.json
43
+ def create
44
+ @attr_val = AttrVal.new(params[:databaseformalizer_attr_val])
45
+
46
+ respond_to do |format|
47
+ if @attr_val.save
48
+ format.html { redirect_to @attr_val, notice: 'Attr val was successfully created.' }
49
+ format.json { render json: @attr_val, status: :created, location: @attr_val }
50
+ else
51
+ format.html { render action: "new" }
52
+ format.json { render json: @attr_val.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /attr_vals/1
58
+ # PUT /attr_vals/1.json
59
+ def update
60
+ @attr_val = AttrVal.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @attr_val.update_attributes(params[:databaseformalizer_attr_val])
64
+ format.html { redirect_to @attr_val, notice: 'Attr val was successfully updated.' }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @attr_val.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /attr_vals/1
74
+ # DELETE /attr_vals/1.json
75
+ def destroy
76
+ @attr_val = AttrVal.find(params[:id])
77
+ @attr_val.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to databaseformalizer_attr_vals_url }
81
+ format.json { head :no_content }
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,7 @@
1
+ module Databaseformalizer
2
+ class DbformahomeController < ApplicationController
3
+
4
+ def index
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,105 @@
1
+ module Databaseformalizer
2
+ class EntitiesController < ApplicationController
3
+ include Databaseformalizer
4
+
5
+ # GET /entities
6
+ # GET /entities.json
7
+ def index
8
+ @entities = Entity.find(:all, :limit=>100)
9
+ EntitiesHelper.setModelGraph("public/images/UMLmodel.png")
10
+
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.json { render json: @entities }
14
+ end
15
+ end
16
+
17
+ # GET /entities/1
18
+ # GET /entities/1.json
19
+ def show
20
+ @entity = Entity.find(params[:id])
21
+
22
+ respond_to do |format|
23
+ format.html # show.html.erb
24
+ format.json { render json: @entity }
25
+ end
26
+ end
27
+
28
+ # GET /entities/new
29
+ # GET /entities/new.json
30
+ def new
31
+ @entity = Entity.new
32
+
33
+ if params[:entity_def] != nil
34
+ @all_entityDefs = EntityDef.find_all_by_entity_def_name(params[:entity_def])
35
+ @entity.entity_def = @all_entityDefs.first
36
+ @type = params[:entity_def]
37
+ else
38
+ @all_entityDefs = EntityDef.all
39
+ @type = "Entity"
40
+ end
41
+ respond_to do |format|
42
+ format.html # new.html.erbe
43
+ format.json { render json: @entity }
44
+ format.js { @entity }
45
+ end
46
+ end
47
+
48
+ # GET /entities/1/edit
49
+ def edit
50
+ @entity = Entity.find(params[:id])
51
+ @all_entityDefs = EntityDef.all
52
+ end
53
+
54
+ # POST /entities
55
+ # POST /entities.json
56
+ def create
57
+ @entity = Entity.new(params[:databaseformalizer_entity])
58
+ @entity.attr_vals.clear
59
+ EntitiesHelper.setAttrVals(params[:attr_vals], @entity)
60
+
61
+ respond_to do |format|
62
+ if @entity.save
63
+ format.html { redirect_to @entity, notice: 'Entity was successfully created.' }
64
+ format.json { render json: @entity, status: :created, location: @entity }
65
+ else
66
+ format.html { render action: "new" }
67
+ format.json { render json: @entity.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # PUT /entities/1
73
+ # PUT /entities/1.json
74
+ def update
75
+ @entity = Entity.find(params[:id])
76
+ @entity.attr_vals.clear
77
+ EntitiesHelper.setAttrVals(params[:attr_vals], @entity)
78
+ @entity.attributes = params[:databaseformalizer_entity]
79
+
80
+ respond_to do |format|
81
+ if @entity.save
82
+ format.html { redirect_to @entity, notice: 'Entity was successfully updated.'}
83
+ format.json { head :no_content }
84
+ else
85
+ format.html { render action: "edit" }
86
+ format.json { render json: @entity.errors, status: :unprocessable_entity }
87
+ end
88
+ end
89
+ end
90
+
91
+ # DELETE /entities/1
92
+ # DELETE /entities/1.json
93
+ def destroy
94
+
95
+ @entity = Entity.find(params[:id])
96
+ @entity.destroy
97
+
98
+ respond_to do |format|
99
+ format.html { redirect_to databaseformalizer_entities_url }
100
+ format.json { head :no_content }
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,90 @@
1
+ module Databaseformalizer
2
+ class EntityDefsController < ApplicationController
3
+ # GET /entity_defs
4
+ # GET /entity_defs.json
5
+ def index
6
+ @entity_defs = EntityDef.all
7
+ EntityDefsHelper.setMetaModelGraph("public/images/UMLmetaModel.png")
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ format.json { render json: @entity_defs }
12
+ end
13
+ end
14
+
15
+ # GET /entity_defs/1
16
+ # GET /entity_defs/1.json
17
+ def show
18
+ @entity_def = EntityDef.find(params[:id])
19
+
20
+ respond_to do |format|
21
+ format.html # show.html.erb
22
+ format.json { render json: @entity_def }
23
+ end
24
+ end
25
+
26
+ # GET /entity_defs/new
27
+ # GET /entity_defs/new.json
28
+ def new
29
+ @entity_def = EntityDef.new
30
+
31
+ respond_to do |format|
32
+ format.html # new.html.erb
33
+ format.json { render json: @entity_def }
34
+ end
35
+ end
36
+
37
+ # GET /entity_defs/1/edit
38
+ def edit
39
+ @entity_def = EntityDef.find(params[:id])
40
+ end
41
+
42
+ # POST /entity_defs
43
+ # POST /entity_defs.json
44
+ def create
45
+ @entity_def = EntityDef.new(params[:databaseformalizer_entity_def])
46
+ if @entity_def.label == ""
47
+ @entity_def.label = @entity_def.entity_def_name
48
+ end
49
+ respond_to do |format|
50
+ if @entity_def.save
51
+ format.html { redirect_to @entity_def, notice: 'Entity def was successfully created.'}
52
+ format.json { render json: @entity_def, status: :created, location: @entity_def }
53
+ else
54
+ format.html { render action: "new" }
55
+ format.json { render json: @entity_def.errors, status: :unprocessable_entity }
56
+ end
57
+ end
58
+ end
59
+
60
+ # PUT /entity_defs/1
61
+ # PUT /entity_defs/1.json
62
+ def update
63
+ @entity_def = EntityDef.find(params[:id])
64
+ if params[:databaseformalizer_entity_def][:attrDef_ids] == nil
65
+ @entity_def.attrDefs.clear
66
+ end
67
+ respond_to do |format|
68
+ if @entity_def.update_attributes(params[:databaseformalizer_entity_def])
69
+ format.html { redirect_to @entity_def, notice: 'Entity def was successfully updated.' }
70
+ format.json { head :no_content }
71
+ else
72
+ format.html { render action: "edit" }
73
+ format.json { render json: @entity_def.errors, status: :unprocessable_entity }
74
+ end
75
+ end
76
+ end
77
+
78
+ # DELETE /entity_defs/1
79
+ # DELETE /entity_defs/1.json
80
+ def destroy
81
+ @entity_def = EntityDef.find(params[:id])
82
+ @entity_def.destroy
83
+
84
+ respond_to do |format|
85
+ format.html { redirect_to databaseformalizer_entity_defs_url }
86
+ format.json { head :no_content }
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,2 @@
1
+ ## Look in lib/application_helper.rb
2
+ ## I can't figure out how to get it included unless I put it that directory
@@ -0,0 +1,4 @@
1
+ module Databaseformalizer
2
+ module ApplicationHelper
3
+ end
4
+ end