radiant 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

Files changed (513) hide show
  1. data/CHANGELOG +33 -1
  2. data/CONTRIBUTORS +15 -2
  3. data/INSTALL +9 -7
  4. data/README +11 -7
  5. data/app/controllers/admin/layouts_controller.rb +5 -2
  6. data/app/controllers/admin/pages_controller.rb +8 -5
  7. data/app/controllers/admin/snippets_controller.rb +5 -2
  8. data/app/controllers/application_controller.rb +7 -0
  9. data/app/helpers/admin/node_helper.rb +2 -2
  10. data/app/helpers/application_helper.rb +2 -2
  11. data/app/models/radiant/config.rb +36 -4
  12. data/app/models/standard_tags.rb +1 -1
  13. data/app/views/admin/layouts/index.html.haml +15 -12
  14. data/app/views/admin/page_parts/_page_part.html.haml +2 -2
  15. data/app/views/admin/pages/index.html.haml +1 -1
  16. data/app/views/admin/snippets/_form.html.haml +1 -1
  17. data/app/views/admin/snippets/index.html.haml +14 -10
  18. data/config/database.db2.yml +20 -0
  19. data/config/environment.rb +4 -4
  20. data/config/environments/test.rb +1 -2
  21. data/features/support/env.rb +2 -1
  22. data/lib/generators/extension/extension_generator.rb +5 -0
  23. data/lib/generators/extension/templates/RSpecRakefile +11 -8
  24. data/lib/generators/extension/templates/cucumber.yml +1 -0
  25. data/lib/generators/extension/templates/cucumber_env.rb +16 -0
  26. data/lib/generators/extension/templates/cucumber_paths.rb +14 -0
  27. data/lib/generators/extension/templates/extension.rb +1 -1
  28. data/lib/generators/instance/instance_generator.rb +1 -1
  29. data/lib/generators/instance/templates/databases/db2.yml +40 -0
  30. data/lib/generators/instance/templates/instance_environment.rb +6 -6
  31. data/lib/local_time.rb +3 -9
  32. data/lib/radiant.rb +1 -1
  33. data/lib/radiant/cache.rb +10 -8
  34. data/lib/radiant/extension.rb +36 -0
  35. data/lib/radiant/extension/script.rb +1 -1
  36. data/lib/radiant/extension_loader.rb +5 -1
  37. data/lib/radiant/initializer.rb +52 -4
  38. data/lib/task_support.rb +33 -0
  39. data/lib/tasks/cucumber.rake +5 -1
  40. data/lib/tasks/radiant_config.rake +18 -0
  41. data/lib/tasks/release.rake +1 -0
  42. data/public/javascripts/admin/admin.js +1 -1
  43. data/spec/controllers/admin/layouts_controller_spec.rb +18 -12
  44. data/spec/controllers/admin/pages_controller_spec.rb +35 -29
  45. data/spec/controllers/admin/snippets_controller_spec.rb +11 -5
  46. data/spec/controllers/admin/welcome_controller_spec.rb +1 -1
  47. data/spec/controllers/application_controller_spec.rb +18 -0
  48. data/spec/fixtures/radiant_config.yml +10 -0
  49. data/spec/generators/extension_generator_spec.rb +12 -0
  50. data/spec/helpers/admin/node_helper_spec.rb +6 -0
  51. data/spec/helpers/application_helper_spec.rb +1 -1
  52. data/spec/lib/radiant/extension_loader_spec.rb +17 -0
  53. data/spec/lib/radiant/extension_spec.rb +28 -0
  54. data/spec/lib/radiant/initializer_spec.rb +34 -0
  55. data/spec/lib/task_support_spec.rb +42 -0
  56. data/spec/models/page_spec.rb +6 -2
  57. data/spec/models/radiant/config_spec.rb +42 -1
  58. data/spec/models/standard_tags_spec.rb +2 -2
  59. data/test/fixtures/extensions/01_basic/app/metal/basic_metal.rb +9 -0
  60. data/test/fixtures/extensions/02_overriding/app/metal/basic_metal.rb +9 -0
  61. data/vendor/extensions/textile_filter/textile.html +2 -2
  62. data/vendor/plugins/dataset/CHANGELOG +2 -1
  63. data/vendor/plugins/dataset/Rakefile +3 -0
  64. data/vendor/plugins/dataset/VERSION.yml +2 -2
  65. data/vendor/plugins/dataset/dataset.gemspec +9 -3
  66. data/vendor/plugins/dataset/lib/dataset.rb +3 -0
  67. data/vendor/radius/lib/radius.rb +5 -0
  68. data/vendor/radius/test/radius_test.rb +6 -0
  69. data/vendor/rails/actionmailer/CHANGELOG +8 -0
  70. data/vendor/rails/actionmailer/Rakefile +3 -2
  71. data/vendor/rails/actionmailer/lib/action_mailer/base.rb +2 -1
  72. data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
  73. data/vendor/rails/actionmailer/test/abstract_unit.rb +0 -3
  74. data/vendor/rails/actionmailer/test/mail_service_test.rb +3 -2
  75. data/vendor/rails/actionpack/CHANGELOG +16 -0
  76. data/vendor/rails/actionpack/Rakefile +5 -3
  77. data/vendor/rails/actionpack/lib/action_controller.rb +2 -7
  78. data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +13 -3
  79. data/vendor/rails/actionpack/lib/action_controller/base.rb +12 -3
  80. data/vendor/rails/actionpack/lib/action_controller/caching.rb +1 -1
  81. data/vendor/rails/actionpack/lib/action_controller/caching/actions.rb +9 -1
  82. data/vendor/rails/actionpack/lib/action_controller/caching/sweeper.rb +45 -0
  83. data/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb +0 -42
  84. data/vendor/rails/actionpack/lib/action_controller/cookies.rb +1 -1
  85. data/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +21 -6
  86. data/vendor/rails/actionpack/lib/action_controller/failsafe.rb +40 -6
  87. data/vendor/rails/actionpack/lib/action_controller/flash.rb +11 -3
  88. data/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +7 -3
  89. data/vendor/rails/actionpack/lib/action_controller/integration.rb +5 -12
  90. data/vendor/rails/actionpack/lib/action_controller/middlewares.rb +0 -1
  91. data/vendor/rails/actionpack/lib/action_controller/params_parser.rb +6 -0
  92. data/vendor/rails/actionpack/lib/action_controller/reloader.rb +47 -7
  93. data/vendor/rails/actionpack/lib/action_controller/request.rb +6 -2
  94. data/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +2 -1
  95. data/vendor/rails/actionpack/lib/action_controller/resources.rb +17 -13
  96. data/vendor/rails/actionpack/lib/action_controller/response.rb +8 -2
  97. data/vendor/rails/actionpack/lib/action_controller/routing.rb +3 -0
  98. data/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb +20 -6
  99. data/vendor/rails/actionpack/lib/action_controller/streaming.rb +4 -2
  100. data/vendor/rails/actionpack/lib/action_controller/test_process.rb +9 -1
  101. data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +1 -1
  102. data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
  103. data/vendor/rails/actionpack/lib/action_view/helpers.rb +1 -1
  104. data/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +21 -9
  105. data/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +1 -1
  106. data/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +2 -2
  107. data/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +26 -12
  108. data/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +71 -1
  109. data/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +10 -4
  110. data/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +1 -1
  111. data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +7 -7
  112. data/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +5 -5
  113. data/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +1 -1
  114. data/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +23 -14
  115. data/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +2 -2
  116. data/vendor/rails/actionpack/lib/action_view/locale/en.yml +4 -0
  117. data/vendor/rails/actionpack/lib/action_view/paths.rb +1 -1
  118. data/vendor/rails/actionpack/lib/action_view/template.rb +22 -33
  119. data/vendor/rails/actionpack/test/abstract_unit.rb +17 -1
  120. data/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +3 -3
  121. data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +27 -0
  122. data/vendor/rails/actionpack/test/controller/caching_test.rb +40 -1
  123. data/vendor/rails/actionpack/test/controller/cookie_test.rb +16 -0
  124. data/vendor/rails/actionpack/test/controller/dispatcher_test.rb +59 -18
  125. data/vendor/rails/actionpack/test/controller/failsafe_test.rb +60 -0
  126. data/vendor/rails/actionpack/test/controller/filter_params_test.rb +3 -1
  127. data/vendor/rails/actionpack/test/controller/flash_test.rb +6 -1
  128. data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +25 -0
  129. data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +63 -9
  130. data/vendor/rails/actionpack/test/controller/integration_test.rb +31 -3
  131. data/vendor/rails/actionpack/test/controller/rack_test.rb +18 -1
  132. data/vendor/rails/actionpack/test/controller/redirect_test.rb +4 -1
  133. data/vendor/rails/actionpack/test/controller/reloader_test.rb +124 -0
  134. data/vendor/rails/actionpack/test/controller/render_test.rb +19 -9
  135. data/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +24 -4
  136. data/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +1 -62
  137. data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +35 -0
  138. data/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +0 -38
  139. data/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +15 -0
  140. data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +6 -5
  141. data/vendor/rails/actionpack/test/controller/request_test.rb +218 -230
  142. data/vendor/rails/actionpack/test/controller/resources_test.rb +52 -0
  143. data/vendor/rails/actionpack/test/controller/routing_test.rb +28 -2
  144. data/vendor/rails/actionpack/test/controller/send_file_test.rb +12 -2
  145. data/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +9 -32
  146. data/vendor/rails/actionpack/test/controller/test_test.rb +8 -0
  147. data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +29 -3
  148. data/vendor/rails/actionpack/test/fixtures/failsafe/500.html +1 -0
  149. data/vendor/rails/actionpack/test/fixtures/public/absolute/test.css +23 -0
  150. data/vendor/rails/actionpack/test/fixtures/public/absolute/test.js +63 -0
  151. data/vendor/rails/actionpack/test/template/active_record_helper_test.rb +1 -1
  152. data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +46 -0
  153. data/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +29 -0
  154. data/vendor/rails/actionpack/test/template/form_helper_test.rb +143 -6
  155. data/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb +27 -0
  156. data/vendor/rails/actionpack/test/template/form_options_helper_test.rb +56 -0
  157. data/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +23 -6
  158. data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +11 -11
  159. data/vendor/rails/actionpack/test/template/template_test.rb +32 -0
  160. data/vendor/rails/actionpack/test/template/text_helper_test.rb +23 -0
  161. data/vendor/rails/actionpack/test/template/url_helper_test.rb +8 -0
  162. data/vendor/rails/activerecord/CHANGELOG +18 -0
  163. data/vendor/rails/activerecord/Rakefile +26 -9
  164. data/vendor/rails/activerecord/examples/performance.rb +162 -0
  165. data/vendor/rails/activerecord/lib/active_record/associations.rb +104 -35
  166. data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +10 -5
  167. data/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +2 -2
  168. data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +22 -4
  169. data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -1
  170. data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +16 -0
  171. data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +1 -0
  172. data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +13 -3
  173. data/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +15 -9
  174. data/vendor/rails/activerecord/lib/active_record/autosave_association.rb +15 -9
  175. data/vendor/rails/activerecord/lib/active_record/base.rb +34 -31
  176. data/vendor/rails/activerecord/lib/active_record/batches.rb +23 -15
  177. data/vendor/rails/activerecord/lib/active_record/calculations.rb +7 -13
  178. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +16 -2
  179. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +2 -2
  180. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +7 -0
  181. data/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +17 -8
  182. data/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +98 -35
  183. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -0
  184. data/vendor/rails/activerecord/lib/active_record/dirty.rb +1 -1
  185. data/vendor/rails/activerecord/lib/active_record/fixtures.rb +14 -11
  186. data/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +1 -1
  187. data/vendor/rails/activerecord/lib/active_record/locale/en.yml +4 -0
  188. data/vendor/rails/activerecord/lib/active_record/named_scope.rb +3 -8
  189. data/vendor/rails/activerecord/lib/active_record/reflection.rb +1 -1
  190. data/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +6 -3
  191. data/vendor/rails/activerecord/lib/active_record/serialization.rb +3 -2
  192. data/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +10 -18
  193. data/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +6 -2
  194. data/vendor/rails/activerecord/lib/active_record/session_store.rb +9 -1
  195. data/vendor/rails/activerecord/lib/active_record/timestamp.rb +39 -9
  196. data/vendor/rails/activerecord/lib/active_record/validations.rb +149 -80
  197. data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
  198. data/vendor/rails/activerecord/test/cases/adapter_test.rb +12 -0
  199. data/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +102 -22
  200. data/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +5 -5
  201. data/vendor/rails/activerecord/test/cases/associations/eager_test.rb +12 -0
  202. data/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb +56 -0
  203. data/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +62 -2
  204. data/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +46 -1
  205. data/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +18 -1
  206. data/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +5 -0
  207. data/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +4 -4
  208. data/vendor/rails/activerecord/test/cases/autosave_association_test.rb +22 -0
  209. data/vendor/rails/activerecord/test/cases/base_test.rb +51 -6
  210. data/vendor/rails/activerecord/test/cases/calculations_test.rb +14 -14
  211. data/vendor/rails/activerecord/test/cases/column_definition_test.rb +34 -0
  212. data/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +5 -5
  213. data/vendor/rails/activerecord/test/cases/dirty_test.rb +10 -0
  214. data/vendor/rails/activerecord/test/cases/finder_test.rb +21 -50
  215. data/vendor/rails/activerecord/test/cases/fixtures_test.rb +6 -1
  216. data/vendor/rails/activerecord/test/cases/helper.rb +1 -2
  217. data/vendor/rails/activerecord/test/cases/i18n_test.rb +5 -0
  218. data/vendor/rails/activerecord/test/cases/json_serialization_test.rb +57 -57
  219. data/vendor/rails/activerecord/test/cases/method_scoping_test.rb +14 -4
  220. data/vendor/rails/activerecord/test/cases/migration_test.rb +39 -11
  221. data/vendor/rails/activerecord/test/cases/modules_test.rb +42 -0
  222. data/vendor/rails/activerecord/test/cases/named_scope_test.rb +6 -4
  223. data/vendor/rails/activerecord/test/cases/pk_test.rb +18 -0
  224. data/vendor/rails/activerecord/test/cases/reflection_test.rb +7 -7
  225. data/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +35 -7
  226. data/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +76 -0
  227. data/vendor/rails/activerecord/test/cases/timestamp_test.rb +75 -0
  228. data/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +656 -624
  229. data/vendor/rails/activerecord/test/cases/validations_test.rb +12 -2
  230. data/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +20 -0
  231. data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite +0 -0
  232. data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 +0 -0
  233. data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite +0 -0
  234. data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 +0 -0
  235. data/vendor/rails/activerecord/test/fixtures/posts.yml +3 -0
  236. data/vendor/rails/activerecord/test/models/author.rb +5 -0
  237. data/vendor/rails/activerecord/test/models/comment.rb +5 -1
  238. data/vendor/rails/activerecord/test/models/company.rb +9 -7
  239. data/vendor/rails/activerecord/test/models/company_in_module.rb +1 -1
  240. data/vendor/rails/activerecord/test/models/contract.rb +5 -0
  241. data/vendor/rails/activerecord/test/models/developer.rb +10 -0
  242. data/vendor/rails/activerecord/test/models/essay.rb +3 -0
  243. data/vendor/rails/activerecord/test/models/organization.rb +2 -0
  244. data/vendor/rails/activerecord/test/models/pet.rb +1 -1
  245. data/vendor/rails/activerecord/test/models/project.rb +1 -1
  246. data/vendor/rails/activerecord/test/models/reply.rb +2 -1
  247. data/vendor/rails/activerecord/test/models/topic.rb +1 -2
  248. data/vendor/rails/activerecord/test/models/toy.rb +2 -0
  249. data/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +13 -2
  250. data/vendor/rails/activerecord/test/schema/schema.rb +19 -0
  251. data/vendor/rails/activeresource/CHANGELOG +16 -0
  252. data/vendor/rails/activeresource/Rakefile +3 -2
  253. data/vendor/rails/activeresource/lib/active_resource/base.rb +89 -9
  254. data/vendor/rails/activeresource/lib/active_resource/connection.rb +73 -8
  255. data/vendor/rails/activeresource/lib/active_resource/exceptions.rb +66 -0
  256. data/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +2 -2
  257. data/vendor/rails/activeresource/lib/active_resource/validations.rb +20 -4
  258. data/vendor/rails/activeresource/lib/active_resource/version.rb +1 -1
  259. data/vendor/rails/activeresource/test/abstract_unit.rb +1 -3
  260. data/vendor/rails/activeresource/test/base/load_test.rb +16 -1
  261. data/vendor/rails/activeresource/test/base_errors_test.rb +56 -19
  262. data/vendor/rails/activeresource/test/base_test.rb +147 -0
  263. data/vendor/rails/activeresource/test/connection_test.rb +42 -0
  264. data/vendor/rails/activeresource/test/debug.log +7974 -0
  265. data/vendor/rails/activeresource/test/fixtures/proxy.rb +4 -0
  266. data/vendor/rails/activesupport/CHANGELOG +13 -0
  267. data/vendor/rails/activesupport/lib/active_support/all.rb +8 -0
  268. data/vendor/rails/activesupport/lib/active_support/cache.rb +14 -1
  269. data/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +16 -10
  270. data/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +1 -1
  271. data/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +1 -0
  272. data/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +2 -1
  273. data/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +2 -4
  274. data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +14 -4
  275. data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +4 -2
  276. data/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +2 -0
  277. data/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +19 -5
  278. data/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +8 -6
  279. data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +15 -9
  280. data/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +1 -0
  281. data/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +29 -5
  282. data/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb +5 -0
  283. data/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +7 -7
  284. data/vendor/rails/activesupport/lib/active_support/deprecation.rb +9 -9
  285. data/vendor/rails/activesupport/lib/active_support/duration.rb +4 -2
  286. data/vendor/rails/activesupport/lib/active_support/json.rb +1 -22
  287. data/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb +38 -0
  288. data/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb +88 -0
  289. data/vendor/rails/activesupport/lib/active_support/json/decoding.rb +23 -72
  290. data/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +9 -8
  291. data/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +9 -8
  292. data/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +14 -9
  293. data/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +4 -2
  294. data/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +21 -11
  295. data/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +4 -2
  296. data/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +16 -0
  297. data/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -2
  298. data/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +4 -0
  299. data/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +5 -32
  300. data/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +2 -2
  301. data/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +9 -8
  302. data/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +4 -2
  303. data/vendor/rails/activesupport/lib/active_support/json/encoding.rb +80 -9
  304. data/vendor/rails/activesupport/lib/active_support/memoizable.rb +1 -1
  305. data/vendor/rails/activesupport/lib/active_support/message_verifier.rb +16 -3
  306. data/vendor/rails/activesupport/lib/active_support/multibyte.rb +30 -6
  307. data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +23 -17
  308. data/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb +61 -0
  309. data/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +28 -0
  310. data/vendor/rails/activesupport/lib/active_support/test_case.rb +9 -8
  311. data/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +2 -0
  312. data/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +9 -8
  313. data/vendor/rails/activesupport/lib/active_support/vendor.rb +6 -7
  314. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -1
  315. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -1
  316. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -1
  317. data/vendor/rails/activesupport/lib/active_support/vendor/{memcache-client-1.6.5 → memcache-client-1.7.4}/memcache.rb +242 -70
  318. data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
  319. data/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb +162 -0
  320. data/vendor/rails/railties/CHANGELOG +10 -0
  321. data/vendor/rails/railties/Rakefile +13 -9
  322. data/vendor/rails/railties/bin/about +2 -2
  323. data/vendor/rails/railties/bin/console +1 -1
  324. data/vendor/rails/railties/bin/dbconsole +1 -1
  325. data/vendor/rails/railties/bin/destroy +1 -1
  326. data/vendor/rails/railties/bin/generate +1 -1
  327. data/vendor/rails/railties/bin/performance/benchmarker +1 -1
  328. data/vendor/rails/railties/bin/performance/profiler +1 -1
  329. data/vendor/rails/railties/bin/plugin +1 -1
  330. data/vendor/rails/railties/bin/runner +1 -1
  331. data/vendor/rails/railties/bin/server +1 -1
  332. data/vendor/rails/railties/builtin/rails_info/rails/info.rb +4 -2
  333. data/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +2 -0
  334. data/vendor/rails/railties/configs/routes.rb +1 -1
  335. data/vendor/rails/railties/configs/seeds.rb +7 -0
  336. data/vendor/rails/railties/environments/boot.rb +1 -1
  337. data/vendor/rails/railties/guides/files/javascripts/code_highlighter.js +188 -0
  338. data/vendor/rails/railties/guides/files/javascripts/guides.js +8 -0
  339. data/vendor/rails/railties/guides/files/javascripts/highlighters.js +90 -0
  340. data/vendor/rails/railties/guides/files/stylesheets/main.css +441 -0
  341. data/vendor/rails/railties/guides/files/stylesheets/print.css +52 -0
  342. data/vendor/rails/railties/guides/files/stylesheets/reset.css +43 -0
  343. data/vendor/rails/railties/guides/files/stylesheets/style.css +13 -0
  344. data/vendor/rails/railties/guides/files/stylesheets/syntax.css +31 -0
  345. data/vendor/rails/railties/guides/images/belongs_to.png +0 -0
  346. data/vendor/rails/railties/guides/images/book_icon.gif +0 -0
  347. data/vendor/rails/railties/guides/images/bullet.gif +0 -0
  348. data/vendor/rails/railties/guides/images/chapters_icon.gif +0 -0
  349. data/vendor/rails/railties/guides/images/check_bullet.gif +0 -0
  350. data/vendor/rails/railties/guides/images/credits_pic_blank.gif +0 -0
  351. data/vendor/rails/railties/guides/images/csrf.png +0 -0
  352. data/vendor/rails/railties/guides/images/customized_error_messages.png +0 -0
  353. data/vendor/rails/railties/guides/images/error_messages.png +0 -0
  354. data/vendor/rails/railties/guides/images/feature_tile.gif +0 -0
  355. data/vendor/rails/railties/guides/images/footer_tile.gif +0 -0
  356. data/vendor/rails/railties/guides/images/fxn.jpg +0 -0
  357. data/vendor/rails/railties/guides/images/grey_bullet.gif +0 -0
  358. data/vendor/rails/railties/guides/images/habtm.png +0 -0
  359. data/vendor/rails/railties/guides/images/has_many.png +0 -0
  360. data/vendor/rails/railties/guides/images/has_many_through.png +0 -0
  361. data/vendor/rails/railties/guides/images/has_one.png +0 -0
  362. data/vendor/rails/railties/guides/images/has_one_through.png +0 -0
  363. data/vendor/rails/railties/guides/images/header_backdrop.png +0 -0
  364. data/vendor/rails/railties/guides/images/header_tile.gif +0 -0
  365. data/vendor/rails/railties/guides/images/i18n/demo_localized_pirate.png +0 -0
  366. data/vendor/rails/railties/guides/images/i18n/demo_translated_en.png +0 -0
  367. data/vendor/rails/railties/guides/images/i18n/demo_translated_pirate.png +0 -0
  368. data/vendor/rails/railties/guides/images/i18n/demo_translation_missing.png +0 -0
  369. data/vendor/rails/railties/guides/images/i18n/demo_untranslated.png +0 -0
  370. data/vendor/rails/railties/guides/images/icons/README +5 -0
  371. data/vendor/rails/railties/guides/images/icons/callouts/1.png +0 -0
  372. data/vendor/rails/railties/guides/images/icons/callouts/10.png +0 -0
  373. data/vendor/rails/railties/guides/images/icons/callouts/11.png +0 -0
  374. data/vendor/rails/railties/guides/images/icons/callouts/12.png +0 -0
  375. data/vendor/rails/railties/guides/images/icons/callouts/13.png +0 -0
  376. data/vendor/rails/railties/guides/images/icons/callouts/14.png +0 -0
  377. data/vendor/rails/railties/guides/images/icons/callouts/15.png +0 -0
  378. data/vendor/rails/railties/guides/images/icons/callouts/2.png +0 -0
  379. data/vendor/rails/railties/guides/images/icons/callouts/3.png +0 -0
  380. data/vendor/rails/railties/guides/images/icons/callouts/4.png +0 -0
  381. data/vendor/rails/railties/guides/images/icons/callouts/5.png +0 -0
  382. data/vendor/rails/railties/guides/images/icons/callouts/6.png +0 -0
  383. data/vendor/rails/railties/guides/images/icons/callouts/7.png +0 -0
  384. data/vendor/rails/railties/guides/images/icons/callouts/8.png +0 -0
  385. data/vendor/rails/railties/guides/images/icons/callouts/9.png +0 -0
  386. data/vendor/rails/railties/guides/images/icons/caution.png +0 -0
  387. data/vendor/rails/railties/guides/images/icons/example.png +0 -0
  388. data/vendor/rails/railties/guides/images/icons/home.png +0 -0
  389. data/vendor/rails/railties/guides/images/icons/important.png +0 -0
  390. data/vendor/rails/railties/guides/images/icons/next.png +0 -0
  391. data/vendor/rails/railties/guides/images/icons/note.png +0 -0
  392. data/vendor/rails/railties/guides/images/icons/prev.png +0 -0
  393. data/vendor/rails/railties/guides/images/icons/tip.png +0 -0
  394. data/vendor/rails/railties/guides/images/icons/up.png +0 -0
  395. data/vendor/rails/railties/guides/images/icons/warning.png +0 -0
  396. data/vendor/rails/railties/guides/images/nav_arrow.gif +0 -0
  397. data/vendor/rails/railties/guides/images/polymorphic.png +0 -0
  398. data/vendor/rails/railties/guides/images/posts_index.png +0 -0
  399. data/vendor/rails/railties/guides/images/rails_guides_logo.gif +0 -0
  400. data/vendor/rails/railties/guides/images/rails_logo_remix.gif +0 -0
  401. data/vendor/rails/railties/guides/images/rails_welcome.png +0 -0
  402. data/vendor/rails/railties/guides/images/session_fixation.png +0 -0
  403. data/vendor/rails/railties/guides/images/tab_grey.gif +0 -0
  404. data/vendor/rails/railties/guides/images/tab_info.gif +0 -0
  405. data/vendor/rails/railties/guides/images/tab_note.gif +0 -0
  406. data/vendor/rails/railties/guides/images/tab_red.gif +0 -0
  407. data/vendor/rails/railties/guides/images/tab_yellow.gif +0 -0
  408. data/vendor/rails/railties/guides/images/tab_yellow.png +0 -0
  409. data/vendor/rails/railties/guides/images/validation_error_messages.png +0 -0
  410. data/vendor/rails/railties/guides/rails_guides.rb +42 -0
  411. data/vendor/rails/railties/guides/rails_guides/generator.rb +138 -0
  412. data/vendor/rails/railties/guides/rails_guides/helpers.rb +34 -0
  413. data/vendor/rails/railties/guides/rails_guides/indexer.rb +55 -0
  414. data/vendor/rails/railties/guides/rails_guides/textile_extensions.rb +41 -0
  415. data/vendor/rails/railties/guides/source/2_2_release_notes.textile +422 -0
  416. data/vendor/rails/railties/guides/source/2_3_release_notes.textile +610 -0
  417. data/vendor/rails/railties/guides/source/action_controller_overview.textile +776 -0
  418. data/vendor/rails/railties/guides/source/action_mailer_basics.textile +424 -0
  419. data/vendor/rails/railties/guides/source/active_record_basics.textile +135 -0
  420. data/vendor/rails/railties/guides/source/active_record_querying.textile +969 -0
  421. data/vendor/rails/railties/guides/source/activerecord_validations_callbacks.textile +1086 -0
  422. data/vendor/rails/railties/guides/source/association_basics.textile +1781 -0
  423. data/vendor/rails/railties/guides/source/caching_with_rails.textile +524 -0
  424. data/vendor/rails/railties/guides/source/command_line.textile +589 -0
  425. data/vendor/rails/railties/guides/source/configuring.textile +234 -0
  426. data/vendor/rails/railties/guides/source/contribute.textile +71 -0
  427. data/vendor/rails/railties/guides/source/contributing_to_rails.textile +239 -0
  428. data/vendor/rails/railties/guides/source/credits.erb.textile +52 -0
  429. data/vendor/rails/railties/guides/source/debugging_rails_applications.textile +709 -0
  430. data/vendor/rails/railties/guides/source/form_helpers.textile +766 -0
  431. data/vendor/rails/railties/guides/source/getting_started.textile +1297 -0
  432. data/vendor/rails/railties/guides/source/i18n.textile +912 -0
  433. data/vendor/rails/railties/guides/source/index.erb.textile +124 -0
  434. data/vendor/rails/railties/guides/source/layout.html.erb +103 -0
  435. data/vendor/rails/railties/guides/source/layouts_and_rendering.textile +979 -0
  436. data/vendor/rails/railties/guides/source/migrations.textile +591 -0
  437. data/vendor/rails/railties/guides/source/nested_model_forms.textile +222 -0
  438. data/vendor/rails/railties/guides/source/performance_testing.textile +531 -0
  439. data/vendor/rails/railties/guides/source/plugins.textile +1512 -0
  440. data/vendor/rails/railties/guides/source/rails_on_rack.textile +309 -0
  441. data/vendor/rails/railties/guides/source/routing.textile +903 -0
  442. data/vendor/rails/railties/guides/source/security.textile +986 -0
  443. data/vendor/rails/railties/guides/source/testing.textile +951 -0
  444. data/vendor/rails/railties/lib/commands/dbconsole.rb +8 -4
  445. data/vendor/rails/railties/lib/commands/performance/profiler.rb +1 -1
  446. data/vendor/rails/railties/lib/initializer.rb +27 -4
  447. data/vendor/rails/railties/lib/rails/gem_dependency.rb +35 -6
  448. data/vendor/rails/railties/lib/rails/plugin.rb +12 -0
  449. data/vendor/rails/railties/lib/rails/plugin/loader.rb +7 -0
  450. data/vendor/rails/railties/lib/rails/rack/metal.rb +1 -1
  451. data/vendor/rails/railties/lib/rails/version.rb +1 -1
  452. data/vendor/rails/railties/lib/rails_generator/base.rb +1 -1
  453. data/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +5 -0
  454. data/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +1 -1
  455. data/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +9 -2
  456. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -0
  457. data/vendor/rails/railties/lib/tasks/databases.rake +17 -4
  458. data/vendor/rails/railties/lib/tasks/gems.rake +19 -6
  459. data/vendor/rails/railties/lib/tasks/routes.rake +4 -3
  460. data/vendor/rails/railties/lib/test_help.rb +4 -1
  461. metadata +158 -58
  462. data/spec/lib/local_time_spec.rb +0 -40
  463. data/vendor/rails/actionpack/lib/action_controller/rewindable_input.rb +0 -28
  464. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb +0 -89
  465. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +0 -22
  466. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +0 -37
  467. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +0 -37
  468. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +0 -58
  469. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +0 -124
  470. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +0 -51
  471. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +0 -55
  472. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +0 -40
  473. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +0 -480
  474. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb +0 -63
  475. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +0 -36
  476. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +0 -49
  477. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +0 -61
  478. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +0 -45
  479. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +0 -29
  480. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +0 -23
  481. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +0 -85
  482. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb +0 -153
  483. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb +0 -88
  484. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb +0 -48
  485. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +0 -61
  486. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +0 -8
  487. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +0 -89
  488. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +0 -55
  489. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +0 -84
  490. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +0 -59
  491. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +0 -8
  492. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +0 -18
  493. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +0 -67
  494. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb +0 -19
  495. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb +0 -462
  496. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +0 -65
  497. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb +0 -16
  498. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +0 -27
  499. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb +0 -204
  500. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb +0 -160
  501. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +0 -57
  502. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +0 -64
  503. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb +0 -241
  504. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb +0 -179
  505. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +0 -142
  506. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +0 -91
  507. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +0 -109
  508. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +0 -100
  509. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +0 -349
  510. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +0 -106
  511. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb +0 -38
  512. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +0 -55
  513. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb +0 -392
@@ -0,0 +1,589 @@
1
+ h2. A Guide to The Rails Command Line
2
+
3
+ Rails comes with every command line tool you'll need to
4
+
5
+ * Create a Rails application
6
+ * Generate models, controllers, database migrations, and unit tests
7
+ * Start a development server
8
+ * Mess with objects through an interactive shell
9
+ * Profile and benchmark your new creation
10
+
11
+ NOTE: This tutorial assumes you have basic Rails knowledge from reading the "Getting Started with Rails Guide":getting_started.html.
12
+
13
+ endprologue.
14
+
15
+ h3. Command Line Basics
16
+
17
+ There are a few commands that are absolutely critical to your everyday usage of Rails. In the order of how much you'll probably use them are:
18
+
19
+ * console
20
+ * server
21
+ * rake
22
+ * generate
23
+ * rails
24
+
25
+ Let's create a simple Rails application to step through each of these commands in context.
26
+
27
+ h4. +rails+
28
+
29
+ The first thing we'll want to do is create a new Rails application by running the +rails+ command after installing Rails.
30
+
31
+ WARNING: You know you need the rails gem installed by typing +gem install rails+ first, right? Okay, okay, just making sure.
32
+
33
+ <shell>
34
+ $ rails commandsapp
35
+
36
+ create
37
+ create app/controllers
38
+ create app/helpers
39
+ create app/models
40
+ ...
41
+ ...
42
+ create log/production.log
43
+ create log/development.log
44
+ create log/test.log
45
+ </shell>
46
+
47
+ Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box.
48
+
49
+ INFO: This output will seem very familiar when we get to the +generate+ command. Creepy foreshadowing!
50
+
51
+ h4. +server+
52
+
53
+ Let's try it! The +server+ command launches a small web server named WEBrick which comes bundled with Ruby. You'll use this any time you want to view your work through a web browser.
54
+
55
+ INFO: WEBrick isn't your only option for serving Rails. We'll get to that in a later section.
56
+
57
+ Without any prodding of any kind, +server+ will run our new shiny Rails app:
58
+
59
+ <shell>
60
+ $ cd commandsapp
61
+ $ ./script/server
62
+ => Booting WEBrick...
63
+ => Rails 2.2.0 application started on http://0.0.0.0:3000
64
+ => Ctrl-C to shutdown server; call with --help for options
65
+ [2008-11-04 10:11:38] INFO WEBrick 1.3.1
66
+ [2008-11-04 10:11:38] INFO ruby 1.8.5 (2006-12-04) [i486-linux]
67
+ [2008-11-04 10:11:38] INFO WEBrick::HTTPServer#start: pid=18994 port=3000
68
+ </shell>
69
+
70
+ WHOA. With just three commands we whipped up a Rails server listening on port 3000. Go! Go right now to your browser and go to http://localhost:3000. I'll wait.
71
+
72
+ See? Cool! It doesn't do much yet, but we'll change that.
73
+
74
+ h4. +generate+
75
+
76
+ The +generate+ command uses templates to create a whole lot of things. You can always find out what's available by running +generate+ by itself. Let's do that:
77
+
78
+ <shell>
79
+ $ ./script/generate
80
+ Usage: ./script/generate generator [options] [args]
81
+
82
+ ...
83
+ ...
84
+
85
+ Installed Generators
86
+ Built-in: controller, integration_test, mailer, migration, model, observer, performance_test, plugin, resource, scaffold, session_migration
87
+
88
+ ...
89
+ ...
90
+ </shell>
91
+
92
+ NOTE: You can install more generators through generator gems, portions of plugins you'll undoubtedly install, and you can even create your own!
93
+
94
+ Using generators will save you a large amount of time by writing *boilerplate code* for you -- necessary for the darn thing to work, but not necessary for you to spend time writing. That's what we have computers for, right?
95
+
96
+ Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator:
97
+
98
+ INFO: All Rails console utilities have help text. As with most *NIX utilities, you can try adding +--help+ or +-h+ to the end, for example +./script/server --help+.
99
+
100
+ <shell>
101
+ $ ./script/generate controller
102
+ Usage: ./script/generate controller ControllerName [options]
103
+
104
+ ...
105
+ ...
106
+
107
+ Example:
108
+ ./script/generate controller CreditCard open debit credit close
109
+
110
+ Credit card controller with URLs like /credit_card/debit.
111
+ Controller: app/controllers/credit_card_controller.rb
112
+ Views: app/views/credit_card/debit.html.erb [...]
113
+ Helper: app/helpers/credit_card_helper.rb
114
+ Test: test/functional/credit_card_controller_test.rb
115
+
116
+ Modules Example:
117
+ ./script/generate controller 'admin/credit_card' suspend late_fee
118
+
119
+ Credit card admin controller with URLs /admin/credit_card/suspend.
120
+ Controller: app/controllers/admin/credit_card_controller.rb
121
+ Views: app/views/admin/credit_card/debit.html.erb [...]
122
+ Helper: app/helpers/admin/credit_card_helper.rb
123
+ Test: test/functional/admin/credit_card_controller_test.rb
124
+ </shell>
125
+
126
+ Ah, the controller generator is expecting parameters in the form of +generate controller ControllerName action1 action2+. Let's make a +Greetings+ controller with an action of *hello*, which will say something nice to us.
127
+
128
+ <shell>
129
+ $ ./script/generate controller Greetings hello
130
+ exists app/controllers/
131
+ exists app/helpers/
132
+ create app/views/greetings
133
+ exists test/functional/
134
+ create app/controllers/greetings_controller.rb
135
+ create test/functional/greetings_controller_test.rb
136
+ create app/helpers/greetings_helper.rb
137
+ create app/views/greetings/hello.html.erb
138
+ </shell>
139
+
140
+ Look there! Now what all did this generate? It looks like it made sure a bunch of directories were in our application, and created a controller file, a functional test file, a helper for the view, and a view file.
141
+
142
+ Let's check out the controller and modify it a little (in +app/controllers/greetings_controller.rb+):
143
+
144
+ <ruby>
145
+ class GreetingsController < ApplicationController
146
+ def hello
147
+ @message = "Hello, how are you today? I am exuberant!"
148
+ end
149
+
150
+ end
151
+ </ruby>
152
+
153
+ Then the view, to display our nice message (in +app/views/greetings/hello.html.erb+):
154
+
155
+ <html>
156
+ <h1>A Greeting for You!</h1>
157
+ <p><%= @message %></p>
158
+ </html>
159
+
160
+ Deal. Go check it out in your browser. Fire up your server. Remember? +./script/server+ at the root of your Rails application should do it.
161
+
162
+ <shell>
163
+ $ ./script/server
164
+ => Booting WEBrick...
165
+ </shell>
166
+
167
+ WARNING: Make sure that you do not have any "tilde backup" files in +app/views/(controller)+, or else WEBrick will _not_ show the expected output. This seems to be a *bug* in Rails 2.3.0.
168
+
169
+ The URL will be +http://localhost:3000/greetings/hello+. I'll wait for you to be suitably impressed.
170
+
171
+ INFO: With a normal, plain-old Rails application, your URLs will generally follow the pattern of http://(host)/(controller)/(action), and a URL like http://(host)/(controller) will hit the *index* action of that controller.
172
+
173
+ "What about data, though?", you ask over a cup of coffee. Rails comes with a generator for data models too. Can you guess its generator name?
174
+
175
+ <shell>
176
+ $ ./script/generate model
177
+ Usage: ./script/generate model ModelName [field:type, field:type]
178
+
179
+ ...
180
+
181
+ Examples:
182
+ ./script/generate model account
183
+
184
+ creates an Account model, test, fixture, and migration:
185
+ Model: app/models/account.rb
186
+ Test: test/unit/account_test.rb
187
+ Fixtures: test/fixtures/accounts.yml
188
+ Migration: db/migrate/XXX_add_accounts.rb
189
+
190
+ ./script/generate model post title:string body:text published:boolean
191
+
192
+ creates a Post model with a string title, text body, and published flag.
193
+ </shell>
194
+
195
+ But instead of generating a model directly (which we'll be doing later), let's set up a scaffold. A *scaffold* in Rails is a full set of model, database migration for that model, controller to manipulate it, views to view and manipulate the data, and a test suite for each of the above.
196
+
197
+ Let's set up a simple resource called "HighScore" that will keep track of our highest score on video games we play.
198
+
199
+ <shell>
200
+ $ ./script/generate scaffold HighScore game:string score:integer
201
+ exists app/models/
202
+ exists app/controllers/
203
+ exists app/helpers/
204
+ create app/views/high_scores
205
+ create app/views/layouts/
206
+ exists test/functional/
207
+ create test/unit/
208
+ create public/stylesheets/
209
+ create app/views/high_scores/index.html.erb
210
+ create app/views/high_scores/show.html.erb
211
+ create app/views/high_scores/new.html.erb
212
+ create app/views/high_scores/edit.html.erb
213
+ create app/views/layouts/high_scores.html.erb
214
+ create public/stylesheets/scaffold.css
215
+ create app/controllers/high_scores_controller.rb
216
+ create test/functional/high_scores_controller_test.rb
217
+ create app/helpers/high_scores_helper.rb
218
+ route map.resources :high_scores
219
+ dependency model
220
+ exists app/models/
221
+ exists test/unit/
222
+ create test/fixtures/
223
+ create app/models/high_score.rb
224
+ create test/unit/high_score_test.rb
225
+ create test/fixtures/high_scores.yml
226
+ exists db/migrate
227
+ create db/migrate/20081217071914_create_high_scores.rb
228
+ </shell>
229
+
230
+ Taking it from the top - the generator checks that there exist the directories for models, controllers, helpers, layouts, functional and unit tests, stylesheets, creates the views, controller, model and database migration for HighScore (creating the +high_scores+ table and fields), takes care of the route for the *resource*, and new tests for everything.
231
+
232
+ The migration requires that we *migrate*, that is, run some Ruby code (living in that +20081217071914_create_high_scores.rb+) to modify the schema of our database. Which database? The sqlite3 database that Rails will create for you when we run the +rake db:migrate+ command. We'll talk more about Rake in-depth in a little while.
233
+
234
+ CAUTION: Hey. Install the sqlite3-ruby gem while you're at it. +gem install sqlite3-ruby+
235
+
236
+ <shell>
237
+ $ rake db:migrate
238
+ (in /home/commandsapp)
239
+ CreateHighScores: migrating
240
+ create_table(:high_scores)
241
+ -> 0.0070s
242
+ CreateHighScores: migrated (0.0077s)
243
+ </shell>
244
+
245
+ INFO: Let's talk about unit tests. Unit tests are code that tests and makes assertions about code. In unit testing, we take a little part of code, say a method of a model, and test its inputs and outputs. Unit tests are your friend. The sooner you make peace with the fact that your quality of life will drastically increase when you unit test your code, the better. Seriously. We'll make one in a moment.
246
+
247
+ Let's see the interface Rails created for us. ./script/server; http://localhost:3000/high_scores
248
+
249
+ We can create new high scores (55,160 on Space Invaders!)
250
+
251
+ h4. +console+
252
+
253
+ The +console+ command lets you interact with your Rails application from the command line. On the underside, +script/console+ uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
254
+
255
+ h4. +dbconsole+
256
+
257
+ +dbconsole+ figures out which database you're using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL, PostgreSQL, SQLite and SQLite3.
258
+
259
+ h4. +plugin+
260
+
261
+ The +plugin+ command simplifies plugin management; think a miniature version of the Gem utility. Let's walk through installing a plugin. You can call the sub-command *discover*, which sifts through repositories looking for plugins, or call *source* to add a specific repository of plugins, or you can specify the plugin location directly.
262
+
263
+ Let's say you're creating a website for a client who wants a small accounting system. Every event having to do with money must be logged, and must never be deleted. Wouldn't it be great if we could override the behavior of a model to never actually take its record out of the database, but *instead*, just set a field?
264
+
265
+ There is such a thing! The plugin we're installing is called "acts_as_paranoid", and it lets models implement a "deleted_at" column that gets set when you call destroy. Later, when calling find, the plugin will tack on a database check to filter out "deleted" things.
266
+
267
+ <shell>
268
+ $ ./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid
269
+ + ./CHANGELOG
270
+ + ./MIT-LICENSE
271
+ ...
272
+ ...
273
+ </shell>
274
+
275
+ h4. +runner+
276
+
277
+ <tt>runner</tt> runs Ruby code in the context of Rails non-interactively. For instance:
278
+
279
+ <shell>
280
+ $ ./script/runner "Model.long_running_method"
281
+ </shell>
282
+
283
+ h4. +destroy+
284
+
285
+ Think of +destroy+ as the opposite of +generate+. It'll figure out what generate did, and undo it. Believe you-me, the creation of this tutorial used this command many times!
286
+
287
+ <shell>
288
+ $ ./script/generate model Oops
289
+ exists app/models/
290
+ exists test/unit/
291
+ exists test/fixtures/
292
+ create app/models/oops.rb
293
+ create test/unit/oops_test.rb
294
+ create test/fixtures/oops.yml
295
+ exists db/migrate
296
+ create db/migrate/20081221040817_create_oops.rb
297
+ $ ./script/destroy model Oops
298
+ notempty db/migrate
299
+ notempty db
300
+ rm db/migrate/20081221040817_create_oops.rb
301
+ rm test/fixtures/oops.yml
302
+ rm test/unit/oops_test.rb
303
+ rm app/models/oops.rb
304
+ notempty test/fixtures
305
+ notempty test
306
+ notempty test/unit
307
+ notempty test
308
+ notempty app/models
309
+ notempty app
310
+ </shell>
311
+
312
+ h4. +about+
313
+
314
+ Check it: Version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application's folder, the current Rails environment name, your app's database adapter, and schema version! +about+ is useful when you need to ask for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation.
315
+
316
+ <shell>
317
+ $ ./script/about
318
+ About your application's environment
319
+ Ruby version 1.8.6 (i486-linux)
320
+ RubyGems version 1.3.1
321
+ Rails version 2.2.0
322
+ Active Record version 2.2.0
323
+ Action Pack version 2.2.0
324
+ Active Resource version 2.2.0
325
+ Action Mailer version 2.2.0
326
+ Active Support version 2.2.0
327
+ Edge Rails revision unknown
328
+ Application root /home/commandsapp
329
+ Environment development
330
+ Database adapter sqlite3
331
+ Database schema version 20081217073400
332
+ </shell>
333
+
334
+ h3. The Rails Advanced Command Line
335
+
336
+ The more advanced uses of the command line are focused around finding useful (even surprising at times) options in the utilities, and fitting utilities to your needs and specific work flow. Listed here are some tricks up Rails' sleeve.
337
+
338
+ h4. Rails with Databases and SCM
339
+
340
+ When creating a new Rails application, you have the option to specify what kind of database and what kind of source code management system your application is going to use. This will save you a few minutes, and certainly many keystrokes.
341
+
342
+ Let's see what a +--git+ option and a +--database=postgresql+ option will do for us:
343
+
344
+ <shell>
345
+ $ mkdir gitapp
346
+ $ cd gitapp
347
+ $ git init
348
+ Initialized empty Git repository in .git/
349
+ $ rails . --git --database=postgresql
350
+ exists
351
+ create app/controllers
352
+ create app/helpers
353
+ ...
354
+ ...
355
+ create tmp/cache
356
+ create tmp/pids
357
+ create Rakefile
358
+ add 'Rakefile'
359
+ create README
360
+ add 'README'
361
+ create app/controllers/application_controller_.rb
362
+ add 'app/controllers/application_controller_.rb'
363
+ create app/helpers/application_helper.rb
364
+ ...
365
+ create log/test.log
366
+ add 'log/test.log'
367
+ </shell>
368
+
369
+ We had to create the *gitapp* directory and initialize an empty git repository before Rails would add files it created to our repository. Let's see what it put in our database configuration:
370
+
371
+ <shell>
372
+ $ cat config/database.yml
373
+ # PostgreSQL. Versions 7.4 and 8.x are supported.
374
+ #
375
+ # Install the ruby-postgres driver:
376
+ # gem install ruby-postgres
377
+ # On Mac OS X:
378
+ # gem install ruby-postgres -- --include=/usr/local/pgsql
379
+ # On Windows:
380
+ # gem install ruby-postgres
381
+ # Choose the win32 build.
382
+ # Install PostgreSQL and put its /bin directory on your path.
383
+ development:
384
+ adapter: postgresql
385
+ encoding: unicode
386
+ database: gitapp_development
387
+ pool: 5
388
+ username: gitapp
389
+ password:
390
+ ...
391
+ ...
392
+ </shell>
393
+
394
+ It also generated some lines in our database.yml configuration corresponding to our choice of PostgreSQL for database. The only catch with using the SCM options is that you have to make your application's directory first, then initialize your SCM, then you can run the +rails+ command to generate the basis of your app.
395
+
396
+ h4. +server+ with Different Backends
397
+
398
+ Many people have created a large number different web servers in Ruby, and many of them can be used to run Rails. Since version 2.3, Rails uses Rack to serve its webpages, which means that any webserver that implements a Rack handler can be used. This includes WEBrick, Mongrel, Thin, and Phusion Passenger (to name a few!).
399
+
400
+ NOTE: For more details on the Rack integration, see "Rails on Rack":rails_on_rack.html.
401
+
402
+ To use a different server, just install its gem, then use its name for the first parameter to +script/server+:
403
+
404
+ <shell>
405
+ $ sudo gem install mongrel
406
+ Building native extensions. This could take a while...
407
+ Building native extensions. This could take a while...
408
+ Successfully installed gem_plugin-0.2.3
409
+ Successfully installed fastthread-1.0.1
410
+ Successfully installed cgi_multipart_eof_fix-2.5.0
411
+ Successfully installed mongrel-1.1.5
412
+ ...
413
+ ...
414
+ Installing RDoc documentation for mongrel-1.1.5...
415
+ $ script/server mongrel
416
+ => Booting Mongrel (use 'script/server webrick' to force WEBrick)
417
+ => Rails 2.2.0 application starting on http://0.0.0.0:3000
418
+ ...
419
+ </shell>
420
+
421
+ h4. The Rails Generation: Generators
422
+
423
+ INFO: For a good rundown on generators, see "Understanding Generators":http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators. A lot of its material is presented here.
424
+
425
+ Generators are code that generates code. Let's experiment by building one. Our generator will generate a text file.
426
+
427
+ The Rails generator by default looks in these places for available generators, where RAILS_ROOT is the root of your Rails application, like /home/foobar/commandsapp:
428
+
429
+ * RAILS_ROOT/lib/generators
430
+ * RAILS_ROOT/vendor/generators
431
+ * Inside any plugin with a directory like "generators" or "rails_generators"
432
+ * ~/.rails/generators
433
+ * Inside any Gem you have installed with a name ending in "_generator"
434
+ * Inside *any* Gem installed with a "rails_generators" path, and a file ending in "_generator.rb"
435
+ * Finally, the builtin Rails generators (controller, model, mailer, etc.)
436
+
437
+ Let's try the fourth option (in our home directory), which will be easy to clean up later:
438
+
439
+ <shell>
440
+ $ mkdir -p ~/.rails/generators/tutorial_test/templates
441
+ $ touch ~/.rails/generators/tutorial_test/templates/tutorial.erb
442
+ $ touch ~/.rails/generators/tutorial_test/tutorial_test_generator.rb
443
+ </shell>
444
+
445
+ We'll fill +tutorial_test_generator.rb+ out with:
446
+
447
+ <ruby>
448
+ class TutorialTestGenerator < Rails::Generator::Base
449
+ def initialize(*runtime_args)
450
+ super(*runtime_args)
451
+ @tut_args = runtime_args
452
+ end
453
+
454
+ def manifest
455
+ record do |m|
456
+ m.directory "public"
457
+ m.template "tutorial.erb", File.join("public", "tutorial.txt"),
458
+ :assigns => { :args => @tut_args }
459
+ end
460
+ end
461
+ end
462
+ </ruby>
463
+
464
+ We take whatever args are supplied, save them to an instance variable, and literally copying from the Rails source, implement a +manifest+ method, which calls +record+ with a block, and we:
465
+
466
+ * Check there's a *public* directory. You bet there is.
467
+ * Run the ERb template called "tutorial.erb".
468
+ * Save it into "RAILS_ROOT/public/tutorial.txt".
469
+ * Pass in the arguments we saved through the +:assign+ parameter.
470
+
471
+ Next we'll build the template:
472
+
473
+ <shell>
474
+ $ cat ~/.rails/generators/tutorial_test/templates/tutorial.erb
475
+ I'm a template!
476
+
477
+ I got assigned some args:
478
+ <%= require 'pp'; PP.pp(args, "") %>
479
+ </shell>
480
+
481
+ Then we'll make sure it got included in the list of available generators:
482
+
483
+ <shell>
484
+ $ ./script/generate
485
+ ...
486
+ ...
487
+ Installed Generators
488
+ User: tutorial_test
489
+ </shell>
490
+
491
+ SWEET! Now let's generate some text, yeah!
492
+
493
+ <shell>
494
+ $ ./script/generate tutorial_test arg1 arg2 arg3
495
+ exists public
496
+ create public/tutorial.txt
497
+ </shell>
498
+
499
+ And the result:
500
+
501
+ <shell>
502
+ $ cat public/tutorial.txt
503
+ I'm a template!
504
+
505
+ I got assigned some args:
506
+ [["arg1", "arg2", "arg3"],
507
+ {:collision=>:ask,
508
+ :quiet=>false,
509
+ :generator=>"tutorial_test",
510
+ :command=>:create}]
511
+ </shell>
512
+
513
+ Tada!
514
+
515
+ h4. Rake is Ruby Make
516
+
517
+ Rake is a standalone Ruby utility that replaces the Unix utility 'make', and uses a 'Rakefile' and +.rake+ files to build up a list of tasks. In Rails, Rake is used for common administration tasks, especially sophisticated ones that build off of each other.
518
+
519
+ You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing +rake --tasks+. Each task has a description, and should help you find the thing you need.
520
+
521
+ <shell>
522
+ rake --tasks
523
+ (in /home/developer/commandsapp)
524
+ rake db:abort_if_pending_migrations # Raises an error if there are pending migrations
525
+ rake db:charset # Retrieves the charset for the current environment's database
526
+ rake db:collation # Retrieves the collation for the current environment's database
527
+ rake db:create # Create the database defined in config/database.yml for the current RAILS_ENV
528
+ ...
529
+ ...
530
+ rake tmp:pids:clear # Clears all files in tmp/pids
531
+ rake tmp:sessions:clear # Clears all files in tmp/sessions
532
+ rake tmp:sockets:clear # Clears all files in tmp/sockets
533
+ </shell>
534
+
535
+ Let's take a look at some of these 80 or so rake tasks.
536
+
537
+ h5. +db:+ Database
538
+
539
+ The most common tasks of the +db:+ Rake namespace are +migrate+ and +create+, and it will pay off to try out all of the migration rake tasks (+up+, +down+, +redo+, +reset+). +rake db:version+ is useful when troubleshooting, telling you the current version of the database.
540
+
541
+ h5. +doc:+ Documentation
542
+
543
+ If you want to strip out or rebuild any of the Rails documentation (including this guide!), the +doc:+ namespace has the tools. Stripping documentation is mainly useful for slimming your codebase, like if you're writing a Rails application for an embedded platform.
544
+
545
+ h5. +gems:+ Ruby gems
546
+
547
+ You can specify which gems your application uses, and +rake gems:install+ will install them for you. Look at your environment.rb to learn how with the *config.gem* directive.
548
+
549
+ NOTE: +gems:unpack+ will unpack, that is internalize your application's Gem dependencies by copying the Gem code into your vendor/gems directory. By doing this you increase your codebase size, but simplify installation on new hosts by eliminating the need to run +rake gems:install+, or finding and installing the gems your application uses.
550
+
551
+ h5. +notes:+ Code note enumeration
552
+
553
+ These tasks will search through your code for commented lines beginning with "FIXME", "OPTIMIZE", "TODO", or any custom annotation (like XXX) and show you them.
554
+
555
+ h5. +rails:+ Rails-specific tasks
556
+
557
+ In addition to the +gems:unpack+ task above, you can also unpack the Rails backend specific gems into vendor/rails by calling +rake rails:freeze:gems+, to unpack the version of Rails you are currently using, or +rake rails:freeze:edge+ to unpack the most recent (cutting, bleeding edge) version.
558
+
559
+ When you have frozen the Rails gems, Rails will prefer to use the code in vendor/rails instead of the system Rails gems. You can "thaw" by running +rake rails:unfreeze+.
560
+
561
+ After upgrading Rails, it is useful to run +rails:update+, which will update your config and scripts directories, and upgrade your Rails-specific javascript (like Scriptaculous).
562
+
563
+ h5. +test:+ Rails tests
564
+
565
+ INFO: A good description of unit testing in Rails is given in "A Guide to Testing Rails Applications":testing.html
566
+
567
+ Rails comes with a test suite called Test::Unit. It is through the use of tests that Rails itself is so stable, and the slew of people working on Rails can prove that everything works as it should.
568
+
569
+ The +test:+ namespace helps in running the different tests you will (hopefully!) write.
570
+
571
+ h5. +time:+ Timezones
572
+
573
+ You can list all the timezones Rails knows about with +rake time:zones:all+, which is useful just in day-to-day life.
574
+
575
+ h5. +tmp:+ Temporary files
576
+
577
+ The tmp directory is, like in the *nix /tmp directory, the holding place for temporary files like sessions (if you're using a file store for files), process id files, and cached actions. The +tmp:+ namespace tasks will help you clear them if you need to if they've become overgrown, or create them in case of an +rm -rf *+ gone awry.
578
+
579
+ h5. Miscellaneous Tasks
580
+
581
+ +rake stats+ is great for looking at statistics on your code, displaying things like KLOCs (thousands of lines of code) and your code to test ratio.
582
+
583
+ +rake secret+ will give you a psuedo-random key to use for your session secret.
584
+
585
+ +rake routes+ will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.
586
+
587
+ h3. Changelog
588
+
589
+ "Lighthouse ticket":http://rails.lighthouseapp.com/projects/16213/tickets/29