railties 3.0.0.beta

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 (334) hide show
  1. data/CHANGELOG +2201 -0
  2. data/README +286 -0
  3. data/bin/rails +11 -0
  4. data/builtin/rails_info/rails/info.rb +147 -0
  5. data/builtin/rails_info/rails/info_controller.rb +15 -0
  6. data/builtin/rails_info/rails/info_helper.rb +2 -0
  7. data/builtin/routes.rb +3 -0
  8. data/guides/files/javascripts/code_highlighter.js +188 -0
  9. data/guides/files/javascripts/guides.js +7 -0
  10. data/guides/files/javascripts/highlighters.js +90 -0
  11. data/guides/files/stylesheets/main.css +441 -0
  12. data/guides/files/stylesheets/print.css +52 -0
  13. data/guides/files/stylesheets/reset.css +43 -0
  14. data/guides/files/stylesheets/style.css +13 -0
  15. data/guides/files/stylesheets/syntax.css +31 -0
  16. data/guides/images/belongs_to.png +0 -0
  17. data/guides/images/book_icon.gif +0 -0
  18. data/guides/images/bullet.gif +0 -0
  19. data/guides/images/chapters_icon.gif +0 -0
  20. data/guides/images/check_bullet.gif +0 -0
  21. data/guides/images/credits_pic_blank.gif +0 -0
  22. data/guides/images/csrf.png +0 -0
  23. data/guides/images/customized_error_messages.png +0 -0
  24. data/guides/images/error_messages.png +0 -0
  25. data/guides/images/feature_tile.gif +0 -0
  26. data/guides/images/footer_tile.gif +0 -0
  27. data/guides/images/fxn.png +0 -0
  28. data/guides/images/grey_bullet.gif +0 -0
  29. data/guides/images/habtm.png +0 -0
  30. data/guides/images/has_many.png +0 -0
  31. data/guides/images/has_many_through.png +0 -0
  32. data/guides/images/has_one.png +0 -0
  33. data/guides/images/has_one_through.png +0 -0
  34. data/guides/images/header_backdrop.png +0 -0
  35. data/guides/images/header_tile.gif +0 -0
  36. data/guides/images/i18n/demo_localized_pirate.png +0 -0
  37. data/guides/images/i18n/demo_translated_en.png +0 -0
  38. data/guides/images/i18n/demo_translated_pirate.png +0 -0
  39. data/guides/images/i18n/demo_translation_missing.png +0 -0
  40. data/guides/images/i18n/demo_untranslated.png +0 -0
  41. data/guides/images/icons/README +5 -0
  42. data/guides/images/icons/callouts/1.png +0 -0
  43. data/guides/images/icons/callouts/10.png +0 -0
  44. data/guides/images/icons/callouts/11.png +0 -0
  45. data/guides/images/icons/callouts/12.png +0 -0
  46. data/guides/images/icons/callouts/13.png +0 -0
  47. data/guides/images/icons/callouts/14.png +0 -0
  48. data/guides/images/icons/callouts/15.png +0 -0
  49. data/guides/images/icons/callouts/2.png +0 -0
  50. data/guides/images/icons/callouts/3.png +0 -0
  51. data/guides/images/icons/callouts/4.png +0 -0
  52. data/guides/images/icons/callouts/5.png +0 -0
  53. data/guides/images/icons/callouts/6.png +0 -0
  54. data/guides/images/icons/callouts/7.png +0 -0
  55. data/guides/images/icons/callouts/8.png +0 -0
  56. data/guides/images/icons/callouts/9.png +0 -0
  57. data/guides/images/icons/caution.png +0 -0
  58. data/guides/images/icons/example.png +0 -0
  59. data/guides/images/icons/home.png +0 -0
  60. data/guides/images/icons/important.png +0 -0
  61. data/guides/images/icons/next.png +0 -0
  62. data/guides/images/icons/note.png +0 -0
  63. data/guides/images/icons/prev.png +0 -0
  64. data/guides/images/icons/tip.png +0 -0
  65. data/guides/images/icons/up.png +0 -0
  66. data/guides/images/icons/warning.png +0 -0
  67. data/guides/images/nav_arrow.gif +0 -0
  68. data/guides/images/polymorphic.png +0 -0
  69. data/guides/images/posts_index.png +0 -0
  70. data/guides/images/rails_guides_logo.gif +0 -0
  71. data/guides/images/rails_logo_remix.gif +0 -0
  72. data/guides/images/rails_welcome.png +0 -0
  73. data/guides/images/session_fixation.png +0 -0
  74. data/guides/images/tab_grey.gif +0 -0
  75. data/guides/images/tab_info.gif +0 -0
  76. data/guides/images/tab_note.gif +0 -0
  77. data/guides/images/tab_red.gif +0 -0
  78. data/guides/images/tab_yellow.gif +0 -0
  79. data/guides/images/tab_yellow.png +0 -0
  80. data/guides/images/validation_error_messages.png +0 -0
  81. data/guides/rails_guides.rb +44 -0
  82. data/guides/rails_guides/generator.rb +178 -0
  83. data/guides/rails_guides/helpers.rb +34 -0
  84. data/guides/rails_guides/indexer.rb +55 -0
  85. data/guides/rails_guides/levenshtein.rb +31 -0
  86. data/guides/rails_guides/textile_extensions.rb +41 -0
  87. data/guides/source/2_2_release_notes.textile +422 -0
  88. data/guides/source/2_3_release_notes.textile +610 -0
  89. data/guides/source/3_0_release_notes.textile +560 -0
  90. data/guides/source/action_controller_overview.textile +783 -0
  91. data/guides/source/action_mailer_basics.textile +437 -0
  92. data/guides/source/action_view_overview.textile +1481 -0
  93. data/guides/source/active_record_basics.textile +204 -0
  94. data/guides/source/active_record_querying.textile +961 -0
  95. data/guides/source/active_support_core_extensions.textile +1835 -0
  96. data/guides/source/activerecord_validations_callbacks.textile +1127 -0
  97. data/guides/source/ajax_on_rails.textile +342 -0
  98. data/guides/source/association_basics.textile +1816 -0
  99. data/guides/source/caching_with_rails.textile +390 -0
  100. data/guides/source/command_line.textile +589 -0
  101. data/guides/source/configuring.textile +290 -0
  102. data/guides/source/contribute.textile +71 -0
  103. data/guides/source/contributing_to_rails.textile +272 -0
  104. data/guides/source/credits.textile.erb +52 -0
  105. data/guides/source/debugging_rails_applications.textile +709 -0
  106. data/guides/source/form_helpers.textile +768 -0
  107. data/guides/source/generators.textile +378 -0
  108. data/guides/source/getting_started.textile +1310 -0
  109. data/guides/source/i18n.textile +879 -0
  110. data/guides/source/index.textile.erb +124 -0
  111. data/guides/source/layout.html.erb +103 -0
  112. data/guides/source/layouts_and_rendering.textile +979 -0
  113. data/guides/source/migrations.textile +591 -0
  114. data/guides/source/nested_model_forms.textile +222 -0
  115. data/guides/source/performance_testing.textile +531 -0
  116. data/guides/source/plugins.textile +1512 -0
  117. data/guides/source/rails_application_templates.textile +238 -0
  118. data/guides/source/rails_on_rack.textile +306 -0
  119. data/guides/source/routing.textile +903 -0
  120. data/guides/source/security.textile +984 -0
  121. data/guides/source/testing.textile +946 -0
  122. data/lib/generators/erb.rb +8 -0
  123. data/lib/generators/erb/controller/controller_generator.rb +21 -0
  124. data/lib/generators/erb/controller/templates/view.html.erb +2 -0
  125. data/lib/generators/erb/mailer/mailer_generator.rb +20 -0
  126. data/lib/generators/erb/mailer/templates/view.text.erb +3 -0
  127. data/lib/generators/erb/scaffold/scaffold_generator.rb +53 -0
  128. data/lib/generators/erb/scaffold/templates/_form.html.erb +13 -0
  129. data/lib/generators/erb/scaffold/templates/edit.html.erb +6 -0
  130. data/lib/generators/erb/scaffold/templates/index.html.erb +27 -0
  131. data/lib/generators/erb/scaffold/templates/layout.html.erb +16 -0
  132. data/lib/generators/erb/scaffold/templates/new.html.erb +5 -0
  133. data/lib/generators/erb/scaffold/templates/show.html.erb +10 -0
  134. data/lib/generators/rails/app/USAGE +9 -0
  135. data/lib/generators/rails/app/app_generator.rb +262 -0
  136. data/lib/generators/rails/app/templates/Gemfile +34 -0
  137. data/lib/generators/rails/app/templates/README +243 -0
  138. data/lib/generators/rails/app/templates/Rakefile +10 -0
  139. data/lib/generators/rails/app/templates/app/controllers/application_controller.rb +3 -0
  140. data/lib/generators/rails/app/templates/app/helpers/application_helper.rb +2 -0
  141. data/lib/generators/rails/app/templates/app/models/.empty_directory +0 -0
  142. data/lib/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
  143. data/lib/generators/rails/app/templates/config.ru +4 -0
  144. data/lib/generators/rails/app/templates/config/application.rb +51 -0
  145. data/lib/generators/rails/app/templates/config/boot.rb +17 -0
  146. data/lib/generators/rails/app/templates/config/databases/frontbase.yml +28 -0
  147. data/lib/generators/rails/app/templates/config/databases/ibm_db.yml +71 -0
  148. data/lib/generators/rails/app/templates/config/databases/mysql.yml +60 -0
  149. data/lib/generators/rails/app/templates/config/databases/oracle.yml +39 -0
  150. data/lib/generators/rails/app/templates/config/databases/postgresql.yml +51 -0
  151. data/lib/generators/rails/app/templates/config/databases/sqlite3.yml +22 -0
  152. data/lib/generators/rails/app/templates/config/environment.rb +5 -0
  153. data/lib/generators/rails/app/templates/config/environments/development.rb.tt +19 -0
  154. data/lib/generators/rails/app/templates/config/environments/production.rb.tt +33 -0
  155. data/lib/generators/rails/app/templates/config/environments/test.rb.tt +29 -0
  156. data/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +7 -0
  157. data/lib/generators/rails/app/templates/config/initializers/cookie_verification_secret.rb.tt +7 -0
  158. data/lib/generators/rails/app/templates/config/initializers/inflections.rb +10 -0
  159. data/lib/generators/rails/app/templates/config/initializers/mime_types.rb +5 -0
  160. data/lib/generators/rails/app/templates/config/initializers/session_store.rb.tt +15 -0
  161. data/lib/generators/rails/app/templates/config/locales/en.yml +5 -0
  162. data/lib/generators/rails/app/templates/config/routes.rb +58 -0
  163. data/lib/generators/rails/app/templates/db/seeds.rb +7 -0
  164. data/lib/generators/rails/app/templates/doc/README_FOR_APP +2 -0
  165. data/lib/generators/rails/app/templates/gitignore +4 -0
  166. data/lib/generators/rails/app/templates/public/404.html +26 -0
  167. data/lib/generators/rails/app/templates/public/422.html +26 -0
  168. data/lib/generators/rails/app/templates/public/500.html +26 -0
  169. data/lib/generators/rails/app/templates/public/favicon.ico +0 -0
  170. data/lib/generators/rails/app/templates/public/images/rails.png +0 -0
  171. data/lib/generators/rails/app/templates/public/index.html +278 -0
  172. data/lib/generators/rails/app/templates/public/javascripts/application.js +2 -0
  173. data/lib/generators/rails/app/templates/public/javascripts/controls.js +963 -0
  174. data/lib/generators/rails/app/templates/public/javascripts/dragdrop.js +973 -0
  175. data/lib/generators/rails/app/templates/public/javascripts/effects.js +1128 -0
  176. data/lib/generators/rails/app/templates/public/javascripts/prototype.js +4320 -0
  177. data/lib/generators/rails/app/templates/public/javascripts/rails.js +110 -0
  178. data/lib/generators/rails/app/templates/public/robots.txt +5 -0
  179. data/lib/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  180. data/lib/generators/rails/app/templates/script/rails +9 -0
  181. data/lib/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  182. data/lib/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  183. data/lib/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  184. data/lib/generators/rails/app/templates/test/performance/browsing_test.rb +9 -0
  185. data/lib/generators/rails/app/templates/test/test_helper.rb +13 -0
  186. data/lib/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  187. data/lib/generators/rails/controller/USAGE +18 -0
  188. data/lib/generators/rails/controller/controller_generator.rb +14 -0
  189. data/lib/generators/rails/controller/templates/controller.rb +7 -0
  190. data/lib/generators/rails/generator/USAGE +11 -0
  191. data/lib/generators/rails/generator/generator_generator.rb +25 -0
  192. data/lib/generators/rails/generator/templates/%file_name%_generator.rb.tt +5 -0
  193. data/lib/generators/rails/generator/templates/USAGE.tt +8 -0
  194. data/lib/generators/rails/generator/templates/templates/.empty_directory +0 -0
  195. data/lib/generators/rails/helper/USAGE +17 -0
  196. data/lib/generators/rails/helper/helper_generator.rb +13 -0
  197. data/lib/generators/rails/helper/templates/helper.rb +2 -0
  198. data/lib/generators/rails/integration_test/USAGE +10 -0
  199. data/lib/generators/rails/integration_test/integration_test_generator.rb +7 -0
  200. data/lib/generators/rails/mailer/USAGE +15 -0
  201. data/lib/generators/rails/mailer/mailer_generator.rb +14 -0
  202. data/lib/generators/rails/mailer/templates/mailer.rb +16 -0
  203. data/lib/generators/rails/metal/USAGE +8 -0
  204. data/lib/generators/rails/metal/metal_generator.rb +11 -0
  205. data/lib/generators/rails/metal/templates/metal.rb +12 -0
  206. data/lib/generators/rails/migration/USAGE +29 -0
  207. data/lib/generators/rails/migration/migration_generator.rb +8 -0
  208. data/lib/generators/rails/model/USAGE +30 -0
  209. data/lib/generators/rails/model/model_generator.rb +8 -0
  210. data/lib/generators/rails/model_subclass/model_subclass_generator.rb +12 -0
  211. data/lib/generators/rails/observer/USAGE +12 -0
  212. data/lib/generators/rails/observer/observer_generator.rb +7 -0
  213. data/lib/generators/rails/performance_test/USAGE +10 -0
  214. data/lib/generators/rails/performance_test/performance_test_generator.rb +7 -0
  215. data/lib/generators/rails/plugin/USAGE +13 -0
  216. data/lib/generators/rails/plugin/plugin_generator.rb +47 -0
  217. data/lib/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
  218. data/lib/generators/rails/plugin/templates/README.tt +13 -0
  219. data/lib/generators/rails/plugin/templates/Rakefile.tt +10 -0
  220. data/lib/generators/rails/plugin/templates/init.rb +1 -0
  221. data/lib/generators/rails/plugin/templates/install.rb +1 -0
  222. data/lib/generators/rails/plugin/templates/lib/%file_name%.rb.tt +1 -0
  223. data/lib/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +4 -0
  224. data/lib/generators/rails/plugin/templates/uninstall.rb +1 -0
  225. data/lib/generators/rails/resource/USAGE +23 -0
  226. data/lib/generators/rails/resource/resource_generator.rb +34 -0
  227. data/lib/generators/rails/scaffold/USAGE +29 -0
  228. data/lib/generators/rails/scaffold/scaffold_generator.rb +13 -0
  229. data/lib/generators/rails/scaffold_controller/USAGE +20 -0
  230. data/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb +27 -0
  231. data/lib/generators/rails/scaffold_controller/templates/controller.rb +85 -0
  232. data/lib/generators/rails/session_migration/USAGE +8 -0
  233. data/lib/generators/rails/session_migration/session_migration_generator.rb +8 -0
  234. data/lib/generators/rails/stylesheets/USAGE +5 -0
  235. data/lib/generators/rails/stylesheets/stylesheets_generator.rb +9 -0
  236. data/lib/generators/rails/stylesheets/templates/scaffold.css +61 -0
  237. data/lib/generators/test_unit.rb +8 -0
  238. data/lib/generators/test_unit/controller/controller_generator.rb +14 -0
  239. data/lib/generators/test_unit/controller/templates/functional_test.rb +8 -0
  240. data/lib/generators/test_unit/helper/helper_generator.rb +13 -0
  241. data/lib/generators/test_unit/helper/templates/helper_test.rb +4 -0
  242. data/lib/generators/test_unit/integration/integration_generator.rb +13 -0
  243. data/lib/generators/test_unit/integration/templates/integration_test.rb +10 -0
  244. data/lib/generators/test_unit/mailer/mailer_generator.rb +21 -0
  245. data/lib/generators/test_unit/mailer/templates/fixture +3 -0
  246. data/lib/generators/test_unit/mailer/templates/functional_test.rb +22 -0
  247. data/lib/generators/test_unit/model/model_generator.rb +24 -0
  248. data/lib/generators/test_unit/model/templates/fixtures.yml +23 -0
  249. data/lib/generators/test_unit/model/templates/unit_test.rb +8 -0
  250. data/lib/generators/test_unit/observer/observer_generator.rb +13 -0
  251. data/lib/generators/test_unit/observer/templates/unit_test.rb +8 -0
  252. data/lib/generators/test_unit/performance/performance_generator.rb +13 -0
  253. data/lib/generators/test_unit/performance/templates/performance_test.rb +9 -0
  254. data/lib/generators/test_unit/plugin/plugin_generator.rb +13 -0
  255. data/lib/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +8 -0
  256. data/lib/generators/test_unit/plugin/templates/test_helper.rb +3 -0
  257. data/lib/generators/test_unit/scaffold/scaffold_generator.rb +18 -0
  258. data/lib/generators/test_unit/scaffold/templates/functional_test.rb +47 -0
  259. data/lib/rails.rb +95 -0
  260. data/lib/rails/all.rb +14 -0
  261. data/lib/rails/application.rb +125 -0
  262. data/lib/rails/application/bootstrap.rb +85 -0
  263. data/lib/rails/application/configurable.rb +19 -0
  264. data/lib/rails/application/configuration.rb +86 -0
  265. data/lib/rails/application/finisher.rb +49 -0
  266. data/lib/rails/application/metal_loader.rb +50 -0
  267. data/lib/rails/application/railties.rb +31 -0
  268. data/lib/rails/application/routes_reloader.rb +46 -0
  269. data/lib/rails/backtrace_cleaner.rb +54 -0
  270. data/lib/rails/code_statistics.rb +107 -0
  271. data/lib/rails/commands.rb +72 -0
  272. data/lib/rails/commands/application.rb +13 -0
  273. data/lib/rails/commands/console.rb +55 -0
  274. data/lib/rails/commands/dbconsole.rb +104 -0
  275. data/lib/rails/commands/destroy.rb +9 -0
  276. data/lib/rails/commands/generate.rb +9 -0
  277. data/lib/rails/commands/performance/benchmarker.rb +23 -0
  278. data/lib/rails/commands/performance/profiler.rb +46 -0
  279. data/lib/rails/commands/plugin.rb +542 -0
  280. data/lib/rails/commands/runner.rb +51 -0
  281. data/lib/rails/commands/server.rb +75 -0
  282. data/lib/rails/commands/update.rb +9 -0
  283. data/lib/rails/configuration.rb +191 -0
  284. data/lib/rails/console/app.rb +33 -0
  285. data/lib/rails/console/helpers.rb +5 -0
  286. data/lib/rails/console/sandbox.rb +6 -0
  287. data/lib/rails/deprecation.rb +62 -0
  288. data/lib/rails/dispatcher.rb +24 -0
  289. data/lib/rails/engine.rb +130 -0
  290. data/lib/rails/engine/configurable.rb +25 -0
  291. data/lib/rails/engine/configuration.rb +49 -0
  292. data/lib/rails/generators.rb +289 -0
  293. data/lib/rails/generators/actions.rb +309 -0
  294. data/lib/rails/generators/active_model.rb +78 -0
  295. data/lib/rails/generators/base.rb +362 -0
  296. data/lib/rails/generators/generated_attribute.rb +48 -0
  297. data/lib/rails/generators/migration.rb +64 -0
  298. data/lib/rails/generators/named_base.rb +95 -0
  299. data/lib/rails/generators/resource_helpers.rb +80 -0
  300. data/lib/rails/generators/test_case.rb +239 -0
  301. data/lib/rails/initializable.rb +97 -0
  302. data/lib/rails/paths.rb +144 -0
  303. data/lib/rails/performance_test_help.rb +3 -0
  304. data/lib/rails/plugin.rb +64 -0
  305. data/lib/rails/rack.rb +8 -0
  306. data/lib/rails/rack/debugger.rb +23 -0
  307. data/lib/rails/rack/log_tailer.rb +33 -0
  308. data/lib/rails/rack/logger.rb +34 -0
  309. data/lib/rails/rack/static.rb +5 -0
  310. data/lib/rails/railtie.rb +74 -0
  311. data/lib/rails/railtie/configurable.rb +23 -0
  312. data/lib/rails/railtie/configuration.rb +9 -0
  313. data/lib/rails/railties_path.rb +1 -0
  314. data/lib/rails/ruby_version_check.rb +10 -0
  315. data/lib/rails/rubyprof_ext.rb +35 -0
  316. data/lib/rails/source_annotation_extractor.rb +102 -0
  317. data/lib/rails/subscriber.rb +108 -0
  318. data/lib/rails/subscriber/test_helper.rb +98 -0
  319. data/lib/rails/tasks.rb +16 -0
  320. data/lib/rails/tasks/annotations.rake +20 -0
  321. data/lib/rails/tasks/documentation.rake +96 -0
  322. data/lib/rails/tasks/framework.rake +69 -0
  323. data/lib/rails/tasks/log.rake +9 -0
  324. data/lib/rails/tasks/middleware.rake +7 -0
  325. data/lib/rails/tasks/misc.rake +71 -0
  326. data/lib/rails/tasks/routes.rake +17 -0
  327. data/lib/rails/tasks/statistics.rake +16 -0
  328. data/lib/rails/tasks/tmp.rake +37 -0
  329. data/lib/rails/test_help.rb +30 -0
  330. data/lib/rails/test_unit/railtie.rb +17 -0
  331. data/lib/rails/test_unit/testing.rake +130 -0
  332. data/lib/rails/version.rb +9 -0
  333. data/lib/rails/webrick_server.rb +156 -0
  334. metadata +427 -0
data/README ADDED
@@ -0,0 +1,286 @@
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" templates
7
+ that are primarily responsible for inserting pre-built data in between HTML tags.
8
+ The model contains the "smart" domain objects (such as Account, Product, Person,
9
+ Post) that holds all the business logic and knows how to persist themselves to
10
+ a database. The controller handles the incoming requests (such as Save New Account,
11
+ Update Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting Started
29
+
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: <tt>rails myapp</tt>
32
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
33
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34
+ 4. Follow the guidelines to start developing your application
35
+
36
+
37
+ == Web Servers
38
+
39
+ By default, Rails will try to use Mongrel if it's installed when started with script/server, otherwise
40
+ Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails with a variety of
41
+ other web servers.
42
+
43
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
44
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
45
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
46
+ More info at: http://mongrel.rubyforge.org
47
+
48
+ Other ruby web servers exist which can run your rails application, however script/server does
49
+ not search for them or start them. These include {Thin}[http://code.macournoyer.com/thin/], {Ebb}[http://ebb.rubyforge.org/], and Apache with {mod_rails}[http://www.modrails.com/].
50
+
51
+ For production use, often a web/proxy server such as {Apache}[http://apache.org], {Nginx}[http://nginx.net/], {LiteSpeed}[http://litespeedtech.com/], {Lighttpd}[http://www.lighttpd.net/] or {IIS}[http://www.iis.net/] is
52
+ deployed as the front-end server, with the chosen ruby web server running in the back-end
53
+ and receiving the proxied requests via one of several protocols (HTTP, CGI, FCGI).
54
+
55
+
56
+ == Apache .htaccess example for FCGI/CGI
57
+
58
+ General Apache options
59
+
60
+ AddHandler fastcgi-script .fcgi
61
+ AddHandler cgi-script .cgi
62
+ Options +FollowSymLinks +ExecCGI
63
+
64
+ If you don't want Rails to look in certain directories, use the following
65
+ rewrite rules so that Apache won't rewrite certain requests.
66
+
67
+ RewriteCond %{REQUEST_URI} ^/notrails.*
68
+ RewriteRule .* - [L]
69
+
70
+ Redirect all requests not available on the filesystem to Rails. By default the
71
+ cgi dispatcher is used which is very slow, for better performance replace the
72
+ dispatcher with the fastcgi one.
73
+
74
+ RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
75
+ RewriteEngine On
76
+
77
+ If your Rails application is accessed via an Alias directive, then you MUST also
78
+ set the RewriteBase in this htaccess file.
79
+
80
+ Alias /myrailsapp /path/to/myrailsapp/public
81
+ RewriteBase /myrailsapp
82
+
83
+ RewriteRule ^$ index.html [QSA]
84
+ RewriteRule ^([^.]+)$ $1.html [QSA]
85
+ RewriteCond %{REQUEST_FILENAME} !-f
86
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
87
+
88
+ Incase Rails experiences terminal errors instead of displaying those messages you
89
+ can supply a file here which will be rendered instead.
90
+
91
+ ErrorDocument 500 /500.html
92
+ ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
93
+
94
+ == Debugging Rails
95
+
96
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
97
+ will help you debug it and get it back on the rails.
98
+
99
+ First area to check is the application log files. Have "tail -f" commands running
100
+ on the server.log and development.log. Rails will automatically display debugging
101
+ and runtime information to these files. Debugging info will also be shown in the
102
+ browser on requests from 127.0.0.1.
103
+
104
+ You can also log your own messages directly into the log file from your code using
105
+ the Ruby logger class from inside your controllers. Example:
106
+
107
+ class WeblogController < ActionController::Base
108
+ def destroy
109
+ @weblog = Weblog.find(params[:id])
110
+ @weblog.destroy
111
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
112
+ end
113
+ end
114
+
115
+ The result will be a message in your log file along the lines of:
116
+
117
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
118
+
119
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
120
+
121
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
122
+
123
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
124
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
125
+
126
+ These two online (and free) books will bring you up to speed on the Ruby language
127
+ and also on programming in general.
128
+
129
+
130
+ == Debugger
131
+
132
+ Debugger support is available through the debugger command when you start your Mongrel or
133
+ Webrick server with --debugger. This means that you can break out of execution at any point
134
+ in the code, investigate and change the model, AND then resume execution!
135
+ You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
136
+ Example:
137
+
138
+ class WeblogController < ActionController::Base
139
+ def index
140
+ @posts = Post.find(:all)
141
+ debugger
142
+ end
143
+ end
144
+
145
+ So the controller will accept the action, run the first line, then present you
146
+ with a IRB prompt in the server window. Here you can do things like:
147
+
148
+ >> @posts.inspect
149
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
150
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
151
+ >> @posts.first.title = "hello from a debugger"
152
+ => "hello from a debugger"
153
+
154
+ ...and even better is that you can examine how your runtime objects actually work:
155
+
156
+ >> f = @posts.first
157
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
158
+ >> f.
159
+ Display all 152 possibilities? (y or n)
160
+
161
+ Finally, when you're ready to resume execution, you enter "cont"
162
+
163
+
164
+ == Console
165
+
166
+ The console is a ruby shell, which allows you to interact with your application's domain
167
+ model. Here you'll have all parts of the application configured, just like it is when the
168
+ application is running. You can inspect domain models, change values, and save to the
169
+ database. Starting the script without arguments will launch it in the development environment.
170
+
171
+ To start the console, just run <tt>script/console</tt> from the application directory.
172
+
173
+ Options:
174
+
175
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications made to the database.
176
+ * Passing an environment name as an argument will load the corresponding environment.
177
+ Example: <tt>script/console production</tt>.
178
+
179
+ More information about irb can be found at link:http://www.rubycentral.com/pickaxe/irb.html
180
+
181
+ == dbconsole
182
+
183
+ You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
184
+ You would be connected to the database with the credentials defined in database.yml.
185
+ Starting the script without arguments will connect you to the development database. Passing an
186
+ argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
187
+ Currently works for mysql, postgresql and sqlite.
188
+
189
+ == Description of Contents
190
+
191
+ The default directory structure of a generated Ruby on Rails applicartion:
192
+
193
+ |-- app
194
+ | |-- controllers
195
+ | |-- helpers
196
+ | |-- models
197
+ | `-- views
198
+ | `-- layouts
199
+ |-- config
200
+ | |-- environments
201
+ | |-- initializers
202
+ | `-- locales
203
+ |-- db
204
+ |-- doc
205
+ |-- lib
206
+ | `-- tasks
207
+ |-- log
208
+ |-- public
209
+ | |-- images
210
+ | |-- javascripts
211
+ | `-- stylesheets
212
+ |-- script
213
+ | `-- performance
214
+ |-- test
215
+ | |-- fixtures
216
+ | |-- functional
217
+ | |-- integration
218
+ | |-- performance
219
+ | `-- unit
220
+ |-- tmp
221
+ | |-- cache
222
+ | |-- pids
223
+ | |-- sessions
224
+ | `-- sockets
225
+ `-- vendor
226
+ `-- plugins
227
+
228
+ app
229
+ Holds all the code that's specific to this particular application.
230
+
231
+ app/controllers
232
+ Holds controllers that should be named like weblogs_controller.rb for
233
+ automated URL mapping. All controllers should descend from ApplicationController
234
+ which itself descends from ActionController::Base.
235
+
236
+ app/models
237
+ Holds models that should be named like post.rb.
238
+ Most models will descend from ActiveRecord::Base.
239
+
240
+ app/views
241
+ Holds the template files for the view that should be named like
242
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
243
+ syntax.
244
+
245
+ app/views/layouts
246
+ Holds the template files for layouts to be used with views. This models the common
247
+ header/footer method of wrapping views. In your views, define a layout using the
248
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
249
+ call <% yield %> to render the view using this layout.
250
+
251
+ app/helpers
252
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
253
+ for you automatically when using script/generate for controllers. Helpers can be used to
254
+ wrap functionality for your views into methods.
255
+
256
+ config
257
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
258
+
259
+ db
260
+ Contains the database schema in schema.rb. db/migrate contains all
261
+ the sequence of Migrations for your schema.
262
+
263
+ doc
264
+ This directory is where your application documentation will be stored when generated
265
+ using <tt>rake doc:app</tt>
266
+
267
+ lib
268
+ Application specific libraries. Basically, any kind of custom code that doesn't
269
+ belong under controllers, models, or helpers. This directory is in the load path.
270
+
271
+ public
272
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
273
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
274
+ set as the DOCUMENT_ROOT of your web server.
275
+
276
+ script
277
+ Helper scripts for automation and generation.
278
+
279
+ test
280
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
281
+ test files will be generated for you and placed in this directory.
282
+
283
+ vendor
284
+ External libraries that the application depends on. Also includes the plugins subdirectory.
285
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
286
+ This directory is in the load path.
@@ -0,0 +1,11 @@
1
+ if File.exists?(Dir.getwd + '/script/rails')
2
+ exec(Dir.getwd + '/script/rails', *ARGV)
3
+ else
4
+ railties_path = File.expand_path('../../lib', __FILE__)
5
+ $:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
6
+
7
+ require 'rails/ruby_version_check'
8
+ Signal.trap("INT") { puts; exit }
9
+
10
+ require 'rails/commands/application'
11
+ end
@@ -0,0 +1,147 @@
1
+ require "active_support/core_ext/object/misc"
2
+ require "cgi"
3
+ require "active_support/core_ext/cgi"
4
+
5
+ module Rails
6
+ module Info
7
+ mattr_accessor :properties
8
+ class << (@@properties = [])
9
+ def names
10
+ map {|val| val.first }
11
+ end
12
+
13
+ def value_for(property_name)
14
+ if property = assoc(property_name)
15
+ property.last
16
+ end
17
+ end
18
+ end
19
+
20
+ class << self #:nodoc:
21
+ def property(name, value = nil)
22
+ value ||= yield
23
+ properties << [name, value] if value
24
+ rescue Exception
25
+ end
26
+
27
+ def frameworks
28
+ %w( active_record action_pack active_resource action_mailer active_support )
29
+ end
30
+
31
+ def framework_version(framework)
32
+ if Object.const_defined?(framework.classify)
33
+ require "#{framework}/version"
34
+ "#{framework.classify}::VERSION::STRING".constantize
35
+ end
36
+ end
37
+
38
+ def edge_rails_revision(info = git_info)
39
+ info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version
40
+ end
41
+
42
+ def freeze_edge_version
43
+ if File.exist?(rails_vendor_root)
44
+ begin
45
+ Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first
46
+ rescue
47
+ Dir[File.join(rails_vendor_root, 'TAG_*')].first.scan(/_(.+)$/).first.first rescue 'unknown'
48
+ end
49
+ end
50
+ end
51
+
52
+ def to_s
53
+ column_width = properties.names.map {|name| name.length}.max
54
+ info = properties.map do |name, value|
55
+ value = value.join(", ") if value.is_a?(Array)
56
+ "%-#{column_width}s %s" % [name, value]
57
+ end
58
+ info.unshift "About your application's environment"
59
+ info * "\n"
60
+ end
61
+
62
+ alias inspect to_s
63
+
64
+ def to_html
65
+ (table = '<table>').tap do
66
+ properties.each do |(name, value)|
67
+ table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
68
+ formatted_value = if value.kind_of?(Array)
69
+ "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
70
+ else
71
+ CGI.escapeHTML(value.to_s)
72
+ end
73
+ table << %(<td class="value">#{formatted_value}</td></tr>)
74
+ end
75
+ table << '</table>'
76
+ end
77
+ end
78
+
79
+ protected
80
+ def rails_vendor_root
81
+ @rails_vendor_root ||= "#{Rails.root}/vendor/rails"
82
+ end
83
+
84
+ def git_info
85
+ env_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C'
86
+ Dir.chdir(rails_vendor_root) do
87
+ silence_stderr { `git log -n 1` }
88
+ end
89
+ ensure
90
+ ENV['LC_ALL'] = env_lang
91
+ end
92
+ end
93
+
94
+ # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)".
95
+ property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})"
96
+
97
+ # The RubyGems version, if it's installed.
98
+ property 'RubyGems version' do
99
+ Gem::RubyGemsVersion
100
+ end
101
+
102
+ property 'Rack version' do
103
+ ::Rack.release
104
+ end
105
+
106
+ # The Rails version.
107
+ property 'Rails version' do
108
+ Rails::VERSION::STRING
109
+ end
110
+
111
+ # Versions of each Rails framework (Active Record, Action Pack,
112
+ # Active Resource, Action Mailer, and Active Support).
113
+ frameworks.each do |framework|
114
+ property "#{framework.titlecase} version" do
115
+ framework_version(framework)
116
+ end
117
+ end
118
+
119
+ property 'Middleware' do
120
+ Rails.configuration.middleware.active.map(&:inspect)
121
+ end
122
+
123
+ # The Rails Git revision, if it's checked out into vendor/rails.
124
+ property 'Edge Rails revision' do
125
+ edge_rails_revision
126
+ end
127
+
128
+ # The application's location on the filesystem.
129
+ property 'Application root' do
130
+ File.expand_path(Rails.root)
131
+ end
132
+
133
+ # The current Rails environment (development, test, or production).
134
+ property 'Environment' do
135
+ Rails.env
136
+ end
137
+
138
+ # The name of the database adapter for the current environment.
139
+ property 'Database adapter' do
140
+ ActiveRecord::Base.configurations[Rails.env]['adapter']
141
+ end
142
+
143
+ property 'Database schema version' do
144
+ ActiveRecord::Migrator.current_version rescue nil
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,15 @@
1
+ class Rails::InfoController < ActionController::Base
2
+ def properties
3
+ if consider_all_requests_local? || local_request?
4
+ render :inline => Rails::Info.to_html
5
+ else
6
+ render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
7
+ end
8
+ end
9
+
10
+ protected
11
+
12
+ def consider_all_requests_local?
13
+ Rails.application.config.consider_all_requests_local
14
+ end
15
+ end