Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:lifo/docrails

  • Loading branch information...
commit d7532c189f26e008fc6ef50336ed5e8168b8221c 2 parents 2c136ae + 6659252
twinturbo authored
Showing with 4,476 additions and 4,273 deletions.
  1. +7 −1 Gemfile
  2. +1 −1  actionmailer/CHANGELOG.md
  3. +3 −3 actionmailer/README.rdoc
  4. +3 −3 actionmailer/lib/action_mailer/base.rb
  5. +1 −1  actionmailer/lib/rails/generators/mailer/templates/mailer.rb
  6. +1 −1  actionmailer/test/i18n_with_controller_test.rb
  7. +2 −2 actionmailer/test/url_test.rb
  8. +12 −1 actionpack/CHANGELOG.md
  9. +1 −1  actionpack/lib/abstract_controller/asset_paths.rb
  10. +5 −2 actionpack/lib/abstract_controller/base.rb
  11. +1 −0  actionpack/lib/abstract_controller/layouts.rb
  12. +1 −1  actionpack/lib/abstract_controller/logger.rb
  13. +1 −1  actionpack/lib/action_controller/caching/sweeping.rb
  14. +23 −3 actionpack/lib/action_controller/metal/data_streaming.rb
  15. +0 −5 actionpack/lib/action_controller/metal/exceptions.rb
  16. +1 −1  actionpack/lib/action_controller/metal/http_authentication.rb
  17. +2 −2 actionpack/lib/action_controller/metal/mime_responds.rb
  18. +2 −2 actionpack/lib/action_controller/metal/params_wrapper.rb
  19. +1 −1  actionpack/lib/action_controller/metal/redirecting.rb
  20. +1 −1  actionpack/lib/action_controller/metal/responder.rb
  21. +4 −4 actionpack/lib/action_controller/metal/streaming.rb
  22. +1 −0  actionpack/lib/action_controller/record_identifier.rb
  23. +3 −6 actionpack/lib/action_controller/test_case.rb
  24. +1 −1  actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
  25. +2 −0  actionpack/lib/action_dispatch/http/mime_negotiation.rb
  26. +1 −1  actionpack/lib/action_dispatch/http/mime_type.rb
  27. +1 −1  actionpack/lib/action_dispatch/http/response.rb
  28. +1 −1  actionpack/lib/action_dispatch/http/upload.rb
  29. +26 −21 actionpack/lib/action_dispatch/http/url.rb
  30. +1 −5 actionpack/lib/action_dispatch/middleware/cookies.rb
  31. +1 −1  actionpack/lib/action_dispatch/middleware/flash.rb
  32. +3 −3 actionpack/lib/action_dispatch/middleware/reloader.rb
  33. +68 −22 actionpack/lib/action_dispatch/middleware/remote_ip.rb
  34. +1 −1  actionpack/lib/action_dispatch/middleware/stack.rb
  35. +31 −4 actionpack/lib/action_dispatch/routing/mapper.rb
  36. +6 −3 actionpack/lib/action_dispatch/routing/redirection.rb
  37. +46 −40 actionpack/lib/action_dispatch/routing/route_set.rb
  38. +4 −2 actionpack/lib/action_dispatch/routing/url_for.rb
  39. +2 −4 actionpack/lib/action_dispatch/testing/assertions/response.rb
  40. +1 −0  actionpack/lib/action_dispatch/testing/assertions/selector.rb
  41. +0 −1  actionpack/lib/action_dispatch/testing/test_request.rb
  42. +8 −2 actionpack/lib/action_view/base.rb
  43. +9 −9 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  44. +28 −28 actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
  45. +23 −23 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
  46. +4 −1 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  47. +1 −1  actionpack/lib/action_view/helpers/capture_helper.rb
  48. +25 −17 actionpack/lib/action_view/helpers/date_helper.rb
  49. +24 −7 actionpack/lib/action_view/helpers/form_helper.rb
  50. +18 −10 actionpack/lib/action_view/helpers/form_tag_helper.rb
  51. +3 −3 actionpack/lib/action_view/helpers/javascript_helper.rb
  52. +7 −7 actionpack/lib/action_view/helpers/number_helper.rb
  53. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  54. +6 −2 actionpack/lib/action_view/helpers/tag_helper.rb
  55. +1 −1  actionpack/lib/action_view/helpers/tags/base.rb
  56. +6 −6 actionpack/lib/action_view/helpers/tags/label.rb
  57. +1 −1  actionpack/lib/action_view/helpers/tags/text_area.rb
  58. +17 −18 actionpack/lib/action_view/helpers/text_helper.rb
  59. +2 −2 actionpack/lib/action_view/helpers/url_helper.rb
  60. +8 −0 actionpack/lib/action_view/railtie.rb
  61. +11 −4 actionpack/lib/action_view/renderer/partial_renderer.rb
  62. +2 −2 actionpack/lib/action_view/renderer/template_renderer.rb
  63. +15 −1 actionpack/test/abstract/layouts_test.rb
  64. +2 −2 actionpack/test/abstract_unit.rb
  65. +1 −1  actionpack/test/activerecord/active_record_store_test.rb
  66. +62 −10 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  67. +10 −10 actionpack/test/controller/action_pack_assertions_test.rb
  68. +7 −0 actionpack/test/controller/assert_select_test.rb
  69. +8 −8 actionpack/test/controller/base_test.rb
  70. +3 −3 actionpack/test/controller/caching_test.rb
  71. +7 −0 actionpack/test/controller/filters_test.rb
  72. +1 −1  actionpack/test/controller/flash_test.rb
  73. +23 −0 actionpack/test/controller/force_ssl_test.rb
  74. +4 −4 actionpack/test/controller/integration_test.rb
  75. +1 −1  actionpack/test/controller/mime_responds_test.rb
  76. +1 −1  actionpack/test/controller/new_base/content_type_test.rb
  77. +2 −2 actionpack/test/controller/new_base/render_streaming_test.rb
  78. +1 −1  actionpack/test/controller/new_base/render_template_test.rb
  79. +2 −2 actionpack/test/controller/new_base/render_test.rb
  80. +2 −2 actionpack/test/controller/new_base/render_text_test.rb
  81. +2 −2 actionpack/test/controller/redirect_test.rb
  82. +2 −1  actionpack/test/controller/render_test.rb
  83. +1 −1  actionpack/test/controller/render_xml_test.rb
  84. +48 −0 actionpack/test/controller/request_forgery_protection_test.rb
  85. +3 −8 actionpack/test/controller/rescue_test.rb
  86. +2 −2 actionpack/test/controller/resources_test.rb
  87. +168 −168 actionpack/test/controller/routing_test.rb
  88. +5 −5 actionpack/test/controller/test_case_test.rb
  89. +16 −16 actionpack/test/controller/url_for_integration_test.rb
  90. +20 −8 actionpack/test/controller/url_for_test.rb
  91. +1 −1  actionpack/test/controller/url_rewriter_test.rb
  92. +1 −1  actionpack/test/controller/webservice_test.rb
  93. +10 −9 actionpack/test/dispatch/mapper_test.rb
  94. +13 −13 actionpack/test/dispatch/prefix_generation_test.rb
  95. +2 −2 actionpack/test/dispatch/request/json_params_parsing_test.rb
  96. +1 −1  actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  97. +1 −1  actionpack/test/dispatch/request/query_string_parsing_test.rb
  98. +1 −1  actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
  99. +2 −2 actionpack/test/dispatch/request/xml_params_parsing_test.rb
  100. +2 −2 actionpack/test/dispatch/request_id_test.rb
  101. +114 −20 actionpack/test/dispatch/request_test.rb
  102. +53 −53 actionpack/test/dispatch/routing_test.rb
  103. +1 −1  actionpack/test/dispatch/session/cache_store_test.rb
  104. +1 −1  actionpack/test/dispatch/session/cookie_store_test.rb
  105. +1 −1  actionpack/test/dispatch/session/mem_cache_store_test.rb
  106. +6 −0 actionpack/test/dispatch/uploaded_file_test.rb
  107. +1 −1  actionpack/test/dispatch/url_generation_test.rb
  108. +1 −1  actionpack/test/fixtures/fun/games/_game.erb
  109. +1 −1  actionpack/test/fixtures/fun/serious/games/_game.erb
  110. +1 −0  actionpack/test/fixtures/games/_game.erb
  111. +93 −93 actionpack/test/template/asset_tag_helper_test.rb
  112. +31 −0 actionpack/test/template/atom_feed_helper_test.rb
  113. +34 −2 actionpack/test/template/date_helper_test.rb
  114. +3 −3 actionpack/test/template/erb/tag_helper_test.rb
  115. +99 −1 actionpack/test/template/form_helper_test.rb
  116. +6 −6 actionpack/test/template/form_tag_helper_test.rb
  117. +2 −2 actionpack/test/template/javascript_helper_test.rb
  118. +21 −34 actionpack/test/template/render_test.rb
  119. +2 −2 actionpack/test/template/tag_helper_test.rb
  120. +1 −1  actionpack/test/template/test_test.rb
  121. +14 −14 actionpack/test/template/url_helper_test.rb
  122. +4 −7 activemodel/README.rdoc
  123. +3 −3 activemodel/lib/active_model/configuration.rb
  124. +2 −1  activemodel/lib/active_model/dirty.rb
  125. +3 −3 activemodel/lib/active_model/errors.rb
  126. +4 −4 activemodel/lib/active_model/lint.rb
  127. +8 −8 activemodel/lib/active_model/model.rb
  128. +0 −1  activemodel/lib/active_model/naming.rb
  129. +14 −8 activemodel/lib/active_model/observing.rb
  130. +4 −7 activemodel/lib/active_model/secure_password.rb
  131. +12 −7 activemodel/lib/active_model/serialization.rb
  132. +15 −2 activemodel/lib/active_model/validations.rb
  133. +2 −1  activemodel/lib/active_model/validations/callbacks.rb
  134. +31 −0 activemodel/lib/active_model/validations/clusivity.rb
  135. +4 −22 activemodel/lib/active_model/validations/exclusion.rb
  136. +4 −22 activemodel/lib/active_model/validations/inclusion.rb
  137. +3 −3 activemodel/lib/active_model/validations/with.rb
  138. +1 −1  activemodel/test/cases/observing_test.rb
  139. +6 −0 activemodel/test/cases/secure_password_test.rb
  140. +45 −1 activerecord/CHANGELOG.md
  141. +2 −0  activerecord/activerecord.gemspec
  142. +1 −0  activerecord/lib/active_record.rb
  143. +4 −9 activerecord/lib/active_record/associations/association.rb
  144. +8 −7 activerecord/lib/active_record/associations/association_scope.rb
  145. +6 −1 activerecord/lib/active_record/associations/belongs_to_association.rb
  146. +2 −1  activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  147. +1 −1  activerecord/lib/active_record/associations/collection_association.rb
  148. +19 −2 activerecord/lib/active_record/associations/collection_proxy.rb
  149. +3 −2 activerecord/lib/active_record/associations/preloader/association.rb
  150. +1 −1  activerecord/lib/active_record/associations/through_association.rb
  151. +0 −8 activerecord/lib/active_record/attribute_methods.rb
  152. +0 −6 activerecord/lib/active_record/attribute_methods/primary_key.rb
  153. +9 −59 activerecord/lib/active_record/attribute_methods/read.rb
  154. +1 −1  activerecord/lib/active_record/base.rb
  155. +39 −20 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  156. +22 −8 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  157. +20 −4 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  158. +3 −2 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  159. +1 −6 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  160. +15 −13 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
  161. +4 −0 activerecord/lib/active_record/connection_adapters/column.rb
  162. +1 −1  activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  163. +42 −8 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  164. +562 −6 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  165. +0 −563 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  166. +9 −4 activerecord/lib/active_record/core.rb
  167. +1 −1  activerecord/lib/active_record/counter_cache.rb
  168. +1 −1  activerecord/lib/active_record/explain.rb
  169. +18 −13 activerecord/lib/active_record/locking/optimistic.rb
  170. +1 −1  activerecord/lib/active_record/model_schema.rb
  171. +1 −1  activerecord/lib/active_record/nested_attributes.rb
  172. +53 −0 activerecord/lib/active_record/null_relation.rb
  173. +19 −15 activerecord/lib/active_record/persistence.rb
  174. +1 −0  activerecord/lib/active_record/querying.rb
  175. +4 −2 activerecord/lib/active_record/railtie.rb
  176. +57 −52 activerecord/lib/active_record/relation.rb
  177. +2 −7 activerecord/lib/active_record/relation/batches.rb
  178. +30 −88 activerecord/lib/active_record/relation/calculations.rb
  179. +63 −111 activerecord/lib/active_record/relation/finder_methods.rb
  180. +121 −0 activerecord/lib/active_record/relation/merger.rb
  181. +2 −2 activerecord/lib/active_record/relation/predicate_builder.rb
  182. +177 −109 activerecord/lib/active_record/relation/query_methods.rb
  183. +31 −119 activerecord/lib/active_record/relation/spawn_methods.rb
  184. +1 −1  activerecord/lib/active_record/schema_dumper.rb
  185. +0 −121 activerecord/lib/active_record/scoping.rb
  186. +5 −6 activerecord/lib/active_record/scoping/default.rb
  187. +11 −14 activerecord/lib/active_record/scoping/named.rb
  188. +1 −1  activerecord/lib/active_record/session_store.rb
  189. +0 −1  activerecord/lib/active_record/validations/uniqueness.rb
  190. +2 −2 activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
  191. +2 −1  activerecord/lib/rails/generators/active_record/model/model_generator.rb
  192. +30 −0 activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
  193. +1 −1  activerecord/test/cases/adapters/mysql/reserved_word_test.rb
  194. +1 −1  activerecord/test/cases/adapters/mysql/schema_test.rb
  195. +2 −2 activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb
  196. +1 −1  activerecord/test/cases/adapters/mysql2/reserved_word_test.rb
  197. +1 −1  activerecord/test/cases/adapters/mysql2/schema_test.rb
  198. +12 −4 activerecord/test/cases/adapters/postgresql/hstore_test.rb
  199. +31 −0 activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
  200. +1 −1  activerecord/test/cases/adapters/sqlite3/quoting_test.rb
  201. +1 −1  activerecord/test/cases/adapters/sqlite3/statement_pool_test.rb
  202. +32 −8 activerecord/test/cases/associations/belongs_to_associations_test.rb
  203. +14 −14 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  204. +2 −2 activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
  205. +2 −2 activerecord/test/cases/associations/eager_load_nested_include_test.rb
  206. +7 −7 activerecord/test/cases/associations/eager_singularization_test.rb
  207. +194 −211 activerecord/test/cases/associations/eager_test.rb
  208. +23 −30 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  209. +66 −95 activerecord/test/cases/associations/has_many_associations_test.rb
  210. +4 −4 activerecord/test/cases/associations/has_many_through_associations_test.rb
  211. +6 −6 activerecord/test/cases/associations/has_one_associations_test.rb
  212. +13 −13 activerecord/test/cases/associations/has_one_through_associations_test.rb
  213. +3 −3 activerecord/test/cases/associations/inner_join_association_test.rb
  214. +27 −27 activerecord/test/cases/associations/inverse_associations_test.rb
  215. +40 −48 activerecord/test/cases/associations/join_model_test.rb
  216. +6 −2 activerecord/test/cases/associations_test.rb
  217. +0 −4 activerecord/test/cases/attribute_methods/read_test.rb
  218. +5 −5 activerecord/test/cases/attribute_methods_test.rb
  219. +19 −15 activerecord/test/cases/autosave_association_test.rb
  220. +84 −119 activerecord/test/cases/base_test.rb
  221. +2 −14 activerecord/test/cases/batches_test.rb
  222. +60 −83 activerecord/test/cases/calculations_test.rb
  223. +24 −0 activerecord/test/cases/connection_pool_test.rb
  224. +1 −1  activerecord/test/cases/custom_locking_test.rb
  225. +0 −30 activerecord/test/cases/deprecated_finder_test.rb
  226. +2 −2 activerecord/test/cases/dirty_test.rb
  227. +3 −1 activerecord/test/cases/explain_test.rb
  228. +96 −199 activerecord/test/cases/finder_test.rb
  229. +1 −1  activerecord/test/cases/fixtures_test.rb
  230. +1 −1  activerecord/test/cases/helper.rb
  231. +16 −16 activerecord/test/cases/inheritance_test.rb
  232. +14 −15 activerecord/test/cases/locking_test.rb
  233. +0 −558 activerecord/test/cases/method_scoping_test.rb
  234. +3 −3 activerecord/test/cases/migration/column_attributes_test.rb
  235. +99 −0 activerecord/test/cases/migration/references_index_test.rb
  236. +3 −3 activerecord/test/cases/migration/rename_column_test.rb
  237. +13 −12 activerecord/test/cases/migration_test.rb
  238. +8 −8 activerecord/test/cases/modules_test.rb
  239. +25 −76 activerecord/test/cases/named_scope_test.rb
  240. +13 −0 activerecord/test/cases/nested_attributes_test.rb
  241. +21 −9 activerecord/test/cases/persistence_test.rb
  242. +3 −3 activerecord/test/cases/query_cache_test.rb
  243. +6 −6 activerecord/test/cases/readonly_test.rb
  244. +1 −1  activerecord/test/cases/reflection_test.rb
  245. +10 −32 activerecord/test/cases/relation_scoping_test.rb
  246. +118 −33 activerecord/test/cases/relation_test.rb
  247. +70 −26 activerecord/test/cases/relations_test.rb
  248. +1 −1  activerecord/test/cases/validations/association_validation_test.rb
  249. +3 −3 activerecord/test/cases/validations/uniqueness_validation_test.rb
  250. +0 −24 activerecord/test/cases/validations_test.rb
  251. +3 −0  activerecord/test/fixtures/peoples_treasures.yml
  252. +0 −1  activerecord/test/models/car.rb
  253. +3 −1 activerecord/test/models/comment.rb
  254. +4 −16 activerecord/test/models/developer.rb
  255. +6 −0 activerecord/test/models/person.rb
  256. +4 −11 activerecord/test/models/post.rb
  257. +2 −18 activerecord/test/models/topic.rb
  258. +27 −2 activerecord/test/schema/postgresql_specific_schema.rb
  259. +7 −0 activerecord/test/schema/schema.rb
  260. +2 −0  activesupport/CHANGELOG.md
  261. +1 −1  activesupport/activesupport.gemspec
  262. +1 −1  activesupport/lib/active_support/benchmarkable.rb
  263. +1 −1  activesupport/lib/active_support/cache/file_store.rb
  264. +1 −1  activesupport/lib/active_support/callbacks.rb
  265. +2 −0  activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
  266. +1 −2  activesupport/lib/active_support/core_ext/hash/deep_dup.rb
  267. +11 −3 activesupport/lib/active_support/core_ext/hash/keys.rb
  268. +3 −3 activesupport/lib/active_support/core_ext/integer/time.rb
  269. +2 −2 activesupport/lib/active_support/core_ext/kernel/debugger.rb
  270. +2 −0  activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
  271. +14 −10 activesupport/lib/active_support/core_ext/module/delegation.rb
  272. +2 −0  activesupport/lib/active_support/core_ext/module/deprecation.rb
  273. +1 −5 activesupport/lib/active_support/core_ext/module/remove_method.rb
  274. +3 −3 activesupport/lib/active_support/core_ext/numeric/time.rb
  275. +0 −1  activesupport/lib/active_support/core_ext/time/calculations.rb
  276. +1 −0  activesupport/lib/active_support/core_ext/time/zones.rb
  277. +1 −0  activesupport/lib/active_support/deprecation.rb
  278. +2 −3 activesupport/lib/active_support/deprecation/method_wrappers.rb
  279. +40 −23 activesupport/lib/active_support/file_update_checker.rb
  280. +4 −4 activesupport/lib/active_support/inflector/methods.rb
  281. +3 −3 activesupport/lib/active_support/json/decoding.rb
  282. +32 −5 activesupport/lib/active_support/notifications.rb
  283. +0 −5 activesupport/lib/active_support/time/autoload.rb
  284. +10 −0 activesupport/test/caching_test.rb
  285. +14 −0 activesupport/test/core_ext/class/attribute_accessor_test.rb
  286. +14 −0 activesupport/test/core_ext/module/attribute_accessor_test.rb
  287. +19 −0 activesupport/test/core_ext/module_test.rb
  288. +2 −2 activesupport/test/file_update_checker_test.rb
  289. +16 −12 activesupport/test/inflector_test_cases.rb
  290. +1 −3 activesupport/test/{buffered_logger_test.rb → logger_test.rb}
  291. BIN  guides/assets/images/favicon.ico
  292. BIN  guides/assets/images/getting_started/confirm_dialog.png
  293. BIN  guides/assets/images/getting_started/form_with_errors.png
  294. BIN  guides/assets/images/getting_started/index_action_with_edit_link.png
  295. BIN  guides/assets/images/getting_started/show_action_for_posts.png
  296. BIN  guides/assets/images/getting_started/undefined_method_post_path.png
  297. BIN  guides/assets/images/posts_index.png
  298. +4 −4 guides/code/getting_started/Gemfile
  299. +2 −2 guides/code/getting_started/README.rdoc
  300. +0 −3  guides/code/getting_started/app/assets/javascripts/comments.js.coffee
Sorry, we could not display the entire diff because too many files (427) changed.
View
8 Gemfile
@@ -18,12 +18,18 @@ else
gem 'journey', :git => "git://github.com/rails/journey"
end
+if ENV['AR_DEPRECATED_FINDERS']
+ gem 'active_record_deprecated_finders', path: ENV['AR_DEPRECATED_FINDERS']
+else
+ gem 'active_record_deprecated_finders', git: 'git://github.com/rails/active_record_deprecated_finders'
+end
+
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
gem 'uglifier', '>= 1.0.3', :require => false
gem 'rake', '>= 0.8.7'
-gem 'mocha', '>= 0.9.8'
+gem 'mocha', '>= 0.11.2'
group :doc do
# The current sdoc cannot generate GitHub links due
View
2  actionmailer/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Rails 3.2.3 (unreleased) ##
+## Rails 3.2.3 (March 30, 2012) ##
* Upgrade mail version to 2.4.3 *ML*
View
6 actionmailer/README.rdoc
@@ -22,12 +22,12 @@ the email.
This can be as simple as:
class Notifier < ActionMailer::Base
- delivers_from 'system@loudthinking.com'
+ default from: 'system@loudthinking.com'
def welcome(recipient)
@recipient = recipient
- mail(:to => recipient,
- :subject => "[Signed up] Welcome #{recipient}")
+ mail(to: recipient,
+ subject: "[Signed up] Welcome #{recipient}")
end
end
View
6 actionmailer/lib/action_mailer/base.rb
@@ -486,7 +486,7 @@ def mailer_name
self.class.mailer_name
end
- # Allows you to pass random and unusual headers to the new +Mail::Message+ object
+ # Allows you to pass random and unusual headers to the new <tt>Mail::Message</tt> object
# which will add them to itself.
#
# headers['X-Special-Domain-Specific-Header'] = "SecretValue"
@@ -497,7 +497,7 @@ def mailer_name
# headers 'X-Special-Domain-Specific-Header' => "SecretValue",
# 'In-Reply-To' => incoming.message_id
#
- # The resulting Mail::Message will have the following in it's header:
+ # The resulting Mail::Message will have the following in its header:
#
# X-Special-Domain-Specific-Header: SecretValue
def headers(args=nil)
@@ -696,7 +696,7 @@ def set_content_type(m, user_content_type, class_default)
# If it does not find a translation for the +subject+ under the specified scope it will default to a
# humanized version of the <tt>action_name</tt>.
def default_i18n_subject #:nodoc:
- mailer_scope = self.class.mailer_name.gsub('/', '.')
+ mailer_scope = self.class.mailer_name.tr('/', '.')
I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)
end
View
2  actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -6,7 +6,7 @@ class <%= class_name %> < ActionMailer::Base
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
- # en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
+ # en.<%= file_path.tr("/",".") %>.<%= action %>.subject
#
def <%= action %>
@greeting = "Hi"
View
2  actionmailer/test/i18n_with_controller_test.rb
@@ -24,7 +24,7 @@ def send_mail
class ActionMailerI18nWithControllerTest < ActionDispatch::IntegrationTest
Routes = ActionDispatch::Routing::RouteSet.new
Routes.draw do
- match ':controller(/:action(/:id))'
+ get ':controller(/:action(/:id))'
end
def app
View
4 actionmailer/test/url_test.rb
@@ -57,8 +57,8 @@ def test_signed_up_with_url
UrlTestMailer.delivery_method = :test
AppRoutes.draw do
- match ':controller(/:action(/:id))'
- match '/welcome' => "foo#bar", :as => "welcome"
+ get ':controller(/:action(/:id))'
+ get '/welcome' => "foo#bar", :as => "welcome"
end
expected = new_mail
View
13 actionpack/CHANGELOG.md
@@ -1,5 +1,14 @@
## Rails 4.0.0 (unreleased) ##
+* Add `index` method to FormBuilder class. *Jorge Bejar*
+
+* Remove the leading \n added by textarea on assert_select. *Santiago Pastorino*
+
+* Changed default value for `config.action_view.embed_authenticity_token_in_remote_forms`
+ to `false`. This change breaks remote forms that need to work also without javascript,
+ so if you need such behavior, you can either set it to `true` or explicitly pass
+ `:authenticity_token => true` in form options
+
* Added ActionDispatch::SSL middleware that when included force all the requests to be under HTTPS protocol. *Rafael Mendonça França*
* Add `include_hidden` option to select tag. With `:include_hidden => false` select with `multiple` attribute doesn't generate hidden input with blank value. *Vasiliy Ermolovich*
@@ -126,7 +135,9 @@
HTML5 `mark` element. *Brian Cardarella*
-## Rails 3.2.3 (unreleased) ##
+## Rails 3.2.3 (March 30, 2012) ##
+
+* Add `config.action_view.embed_authenticity_token_in_remote_forms` (defaults to true) which allows to set if authenticity token will be included by default in remote forms. If you change it to false, you can still force authenticity token by passing `:authenticity_token => true` in form options *Piotr Sarnacki*
* Do not include the authenticity token in forms where remote: true as ajax forms use the meta-tag value *DHH*
View
2  actionpack/lib/abstract_controller/asset_paths.rb
@@ -1,5 +1,5 @@
module AbstractController
- module AssetPaths
+ module AssetPaths #:nodoc:
extend ActiveSupport::Concern
included do
View
7 actionpack/lib/abstract_controller/base.rb
@@ -5,8 +5,11 @@
require 'active_support/core_ext/module/anonymous'
module AbstractController
- class Error < StandardError; end
- class ActionNotFound < StandardError; end
+ class Error < StandardError #:nodoc:
+ end
+
+ class ActionNotFound < StandardError #:nodoc:
+ end
# <tt>AbstractController::Base</tt> is a low-level API. Nobody should be
# using it directly, and subclasses (like ActionController::Base) are
View
1  actionpack/lib/abstract_controller/layouts.rb
@@ -249,6 +249,7 @@ def conditional_layout?
# Symbol:: call the method specified by the symbol, which will return the template name
# false:: There is no layout
# true:: raise an ArgumentError
+ # nil:: Force default layout behavior with inheritance
#
# ==== Parameters
# * <tt>layout</tt> - The layout to use.
View
2  actionpack/lib/abstract_controller/logger.rb
@@ -1,7 +1,7 @@
require "active_support/benchmarkable"
module AbstractController
- module Logger
+ module Logger #:nodoc:
extend ActiveSupport::Concern
included do
View
2  actionpack/lib/action_controller/caching/sweeping.rb
@@ -93,7 +93,7 @@ def callback(timing)
end
def method_missing(method, *arguments, &block)
- super unless @controller
+ return super unless @controller
@controller.__send__(method, *arguments, &block)
end
end
View
26 actionpack/lib/action_controller/metal/data_streaming.rb
@@ -16,7 +16,7 @@ module DataStreaming
protected
# Sends the file. This uses a server-appropriate method (such as X-Sendfile)
# via the Rack::Sendfile middleware. The header to use is set via
- # config.action_dispatch.x_sendfile_header.
+ # +config.action_dispatch.x_sendfile_header+.
# Your server can also configure this for you by setting the X-Sendfile-Type header.
#
# Be careful to sanitize the path parameter if it is coming from a web
@@ -74,7 +74,27 @@ def send_file(path, options = {}) #:doc:
self.status = options[:status] || 200
self.content_type = options[:content_type] if options.key?(:content_type)
- self.response_body = File.open(path, "rb")
+ self.response_body = FileBody.new(path)
+ end
+
+ # Avoid having to pass an open file handle as the response body.
+ # Rack::Sendfile will usually intercepts the response and just uses
+ # the path directly, so no reason to open the file.
+ class FileBody #:nodoc:
+ attr_reader :to_path
+
+ def initialize(path)
+ @to_path = path
+ end
+
+ # Stream the file's contents if Rack::Sendfile isn't present.
+ def each
+ File.open(to_path, 'rb') do |file|
+ while chunk = file.read(16384)
+ yield chunk
+ end
+ end
+ end
end
# Sends the given binary data to the browser. This method is similar to
@@ -132,7 +152,7 @@ def send_file_headers!(options)
else
if !type_provided && options[:filename]
# If type wasn't provided, try guessing from file extension.
- content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.tr('.','')) || content_type
+ content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.delete('.')) || content_type
end
self.content_type = content_type
end
View
5 actionpack/lib/action_controller/metal/exceptions.rb
@@ -14,8 +14,6 @@ def initialize(message, failures=[])
end
class MethodNotAllowed < ActionControllerError #:nodoc:
- attr_reader :allowed_methods
-
def initialize(*allowed_methods)
super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
end
@@ -30,9 +28,6 @@ class UnknownController < ActionControllerError #:nodoc:
class MissingFile < ActionControllerError #:nodoc:
end
- class RenderError < ActionControllerError #:nodoc:
- end
-
class SessionOverflowError < ActionControllerError #:nodoc:
DEFAULT_MESSAGE = 'Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data.'
View
2  actionpack/lib/action_controller/metal/http_authentication.rb
@@ -229,7 +229,7 @@ def decode_credentials_header(request)
def decode_credentials(header)
Hash[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
key, value = pair.split('=', 2)
- [key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')]
+ [key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').delete('\'')]
end]
end
View
4 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -74,7 +74,7 @@ def clear_respond_to
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people.to_xml }
+ # format.xml { render :xml => @people }
# end
# end
#
@@ -389,7 +389,7 @@ def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people.to_xml }
+ # format.xml { render :xml => @people }
# end
#
# In this usage, the argument passed to the block (+format+ above) is an
View
4 actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -48,7 +48,7 @@ module ActionController
# method attribute_names.
#
# If you're going to pass the parameters to an +ActiveModel+ object (such as
- # +User.new(params[:user])+), you might consider passing the model class to
+ # <tt>User.new(params[:user])</tt>), you might consider passing the model class to
# the method instead. The +ParamsWrapper+ will actually try to determine the
# list of attribute names from the model and only wrap those attributes:
#
@@ -66,7 +66,7 @@ module ActionController
# class Admin::UsersController < ApplicationController
# end
#
- # will try to check if +Admin::User+ or +User+ model exists, and use it to
+ # will try to check if <tt>Admin::User</tt> or +User+ model exists, and use it to
# determine the wrapper key respectively. If both models don't exist,
# it will then fallback to use +user+ as the key.
module ParamsWrapper
View
2  actionpack/lib/action_controller/metal/redirecting.rb
@@ -93,7 +93,7 @@ def _compute_redirect_to_location(options)
_compute_redirect_to_location options.call
else
url_for(options)
- end.gsub(/[\0\r\n]/, '')
+ end.delete("\0\r\n")
end
end
end
View
2  actionpack/lib/action_controller/metal/responder.rb
@@ -63,7 +63,7 @@ module ActionController #:nodoc:
#
# def create
# @project = Project.find(params[:project_id])
- # @task = @project.comments.build(params[:task])
+ # @task = @project.tasks.build(params[:task])
# flash[:notice] = 'Task was successfully created.' if @task.save
# respond_with(@project, @task)
# end
View
8 actionpack/lib/action_controller/metal/streaming.rb
@@ -139,17 +139,17 @@ module ActionController #:nodoc:
# session or flash after the template starts rendering will not propagate
# to the client.
#
- # If you try to modify cookies, session or flash, an +ActionDispatch::ClosedError+
+ # If you try to modify cookies, session or flash, an <tt>ActionDispatch::ClosedError</tt>
# will be raised, showing those objects are closed for modification.
#
# == Middlewares
#
# Middlewares that need to manipulate the body won't work with streaming.
# You should disable those middlewares whenever streaming in development
- # or production. For instance, +Rack::Bug+ won't work when streaming as it
+ # or production. For instance, <tt>Rack::Bug</tt> won't work when streaming as it
# needs to inject contents in the HTML body.
#
- # Also +Rack::Cache+ won't work with streaming as it does not support
+ # Also <tt>Rack::Cache</tt> won't work with streaming as it does not support
# streaming bodies yet. Whenever streaming Cache-Control is automatically
# set to "no-cache".
#
@@ -162,7 +162,7 @@ module ActionController #:nodoc:
# Currently, when an exception happens in development or production, Rails
# will automatically stream to the client:
#
- # "><script type="text/javascript">window.location = "/500.html"</script></html>
+ # "><script>window.location = "/500.html"</script></html>
#
# The first two characters (">) are required in case the exception happens
# while rendering attributes for a given tag. You can check the real cause
View
1  actionpack/lib/action_controller/record_identifier.rb
@@ -53,6 +53,7 @@ def dom_class(record_or_class, prefix = nil)
# If you need to address multiple instances of the same class in the same view, you can prefix the dom_id:
#
# dom_id(Post.find(45), :edit) # => "edit_post_45"
+ # dom_id(Post.new, :custom) # => "custom_post"
def dom_id(record, prefix = nil)
if record_id = record_key_for_dom_id(record)
"#{dom_class(record, prefix)}#{JOIN}#{record_id}"
View
9 actionpack/lib/action_controller/test_case.rb
@@ -27,13 +27,13 @@ def setup_subscriptions
path = payload[:virtual_path]
next unless path
partial = path =~ /^.*\/_[^\/]*$/
+
if partial
@partials[path] += 1
@partials[path.split("/").last] += 1
- @templates[path] += 1
- else
- @templates[path] += 1
end
+
+ @templates[path] += 1
end
end
@@ -140,9 +140,6 @@ def initialize(env = {})
class Result < ::Array #:nodoc:
def to_s() join '/' end
- def self.new_escaped(strings)
- new strings.collect {|str| uri_parser.unescape str}
- end
end
def assign_parameters(routes, controller_path, action, parameters = {})
View
2  actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
@@ -99,7 +99,7 @@ class WhiteListSanitizer < Sanitizer
self.allowed_protocols = Set.new(%w(ed2k ftp http https irc mailto news gopher nntp telnet webcal xmpp callto
feed svn urn aim rsync tag ssh sftp rtsp afs))
- # Specifies the default Set of acceptable css keywords that #sanitize and #sanitize_css will accept.
+ # Specifies the default Set of acceptable css properties that #sanitize and #sanitize_css will accept.
self.allowed_css_properties = Set.new(%w(azimuth background-color border-bottom-color border-collapse
border-color border-left-color border-right-color border-top-color clear color cursor direction display
elevation float font font-family font-size font-style font-variant font-weight height letter-spacing line-height
View
2  actionpack/lib/action_dispatch/http/mime_negotiation.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/module/attribute_accessors'
+
module ActionDispatch
module Http
module MimeNegotiation
View
2  actionpack/lib/action_dispatch/http/mime_type.rb
@@ -38,7 +38,7 @@ def self.[](type)
# respond_to do |format|
# format.html
# format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"] }
- # format.xml { render :xml => @people.to_xml }
+ # format.xml { render :xml => @people }
# end
# end
# end
View
2  actionpack/lib/action_dispatch/http/response.rb
@@ -29,7 +29,7 @@ module ActionDispatch # :nodoc:
# class DemoControllerTest < ActionDispatch::IntegrationTest
# def test_print_root_path_to_console
# get('/')
- # puts @response.body
+ # puts response.body
# end
# end
class Response
View
2  actionpack/lib/action_dispatch/http/upload.rb
@@ -17,7 +17,7 @@ def read(*args)
end
# Delegate these methods to the tempfile.
- [:open, :path, :rewind, :size].each do |method|
+ [:open, :path, :rewind, :size, :eof?].each do |method|
class_eval "def #{method}; @tempfile.#{method}; end"
end
View
47 actionpack/lib/action_dispatch/http/url.rb
@@ -23,23 +23,6 @@ def extract_subdomain(host, tld_length = @@tld_length)
end
def url_for(options = {})
- if options[:host].blank? && options[:only_path].blank?
- raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true'
- end
-
- rewritten_url = ""
-
- unless options[:only_path]
- unless options[:protocol] == false
- rewritten_url << (options[:protocol] || "http")
- rewritten_url << ":" unless rewritten_url.match(%r{:|//})
- end
- rewritten_url << "//" unless rewritten_url.match("//")
- rewritten_url << rewrite_authentication(options)
- rewritten_url << host_or_subdomain_and_domain(options)
- rewritten_url << ":#{options.delete(:port)}" if options[:port]
- end
-
path = ""
path << options.delete(:script_name).to_s.chomp("/")
path << options.delete(:path).to_s
@@ -47,14 +30,36 @@ def url_for(options = {})
params = options[:params] || {}
params.reject! {|k,v| v.to_param.nil? }
- rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
- rewritten_url << "?#{params.to_query}" unless params.empty?
- rewritten_url << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor]
- rewritten_url
+ result = build_host_url(options)
+
+ result << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
+ result << "?#{params.to_query}" unless params.empty?
+ result << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor]
+ result
end
private
+ def build_host_url(options)
+ if options[:host].blank? && options[:only_path].blank?
+ raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true'
+ end
+
+ result = ""
+
+ unless options[:only_path]
+ unless options[:protocol] == false
+ result << (options[:protocol] || "http")
+ result << ":" unless result.match(%r{:|//})
+ end
+ result << "//" unless result.match("//")
+ result << rewrite_authentication(options)
+ result << host_or_subdomain_and_domain(options)
+ result << ":#{options.delete(:port)}" if options[:port]
+ end
+ result
+ end
+
def named_host?(host)
host && IP_HOST_REGEXP !~ host
end
View
6 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -225,7 +225,7 @@ def permanent
# cookie was tampered with by the user (or a 3rd party), an ActiveSupport::MessageVerifier::InvalidSignature exception will
# be raised.
#
- # This jar requires that you set a suitable secret for the verification on your app's config.secret_token.
+ # This jar requires that you set a suitable secret for the verification on your app's +config.secret_token+.
#
# Example:
#
@@ -273,10 +273,6 @@ def []=(key, options)
@parent_jar[key] = options
end
- def signed
- @signed ||= SignedCookieJar.new(self, @secret)
- end
-
def method_missing(method, *arguments, &block)
@parent_jar.send(method, *arguments, &block)
end
View
2  actionpack/lib/action_dispatch/middleware/flash.rb
@@ -17,7 +17,7 @@ def flash
# def create
# # save post
# flash[:notice] = "Post successfully created"
- # redirect_to posts_path(@post)
+ # redirect_to @post
# end
#
# def show
View
6 actionpack/lib/action_dispatch/middleware/reloader.rb
@@ -18,10 +18,10 @@ module ActionDispatch
# classes before they are unloaded.
#
# By default, ActionDispatch::Reloader is included in the middleware stack
- # only in the development environment; specifically, when config.cache_classes
+ # only in the development environment; specifically, when +config.cache_classes+
# is false. Callbacks may be registered even when it is not included in the
- # middleware stack, but are executed only when +ActionDispatch::Reloader.prepare!+
- # or +ActionDispatch::Reloader.cleanup!+ are called manually.
+ # middleware stack, but are executed only when <tt>ActionDispatch::Reloader.prepare!</tt>
+ # or <tt>ActionDispatch::Reloader.cleanup!</tt> are called manually.
#
class Reloader
include ActiveSupport::Callbacks
View
90 actionpack/lib/action_dispatch/middleware/remote_ip.rb
@@ -5,11 +5,14 @@ class IpSpoofAttackError < StandardError ; end
# IP addresses that are "trusted proxies" that can be stripped from
# the comma-delimited list in the X-Forwarded-For header. See also:
# http://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
+ # http://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses.
TRUSTED_PROXIES = %r{
^127\.0\.0\.1$ | # localhost
+ ^::1$ |
^(10 | # private IP 10.x.x.x
172\.(1[6-9]|2[0-9]|3[0-1]) | # private IP in the range 172.16.0.0 .. 172.31.255.255
- 192\.168 # private IP 192.168.x.x
+ 192\.168 | # private IP 192.168.x.x
+ fc00:: # private IP fc00
)\.
}x
@@ -19,13 +22,13 @@ def initialize(app, check_ip_spoofing = true, custom_proxies = nil)
@app = app
@check_ip = check_ip_spoofing
@proxies = case custom_proxies
- when Regexp
- custom_proxies
- when nil
- TRUSTED_PROXIES
- else
- Regexp.union(TRUSTED_PROXIES, custom_proxies)
- end
+ when Regexp
+ custom_proxies
+ when nil
+ TRUSTED_PROXIES
+ else
+ Regexp.union(TRUSTED_PROXIES, custom_proxies)
+ end
end
def call(env)
@@ -34,6 +37,31 @@ def call(env)
end
class GetIp
+
+ # IP v4 and v6 (with compression) validation regexp
+ # https://gist.github.com/1289635
+ VALID_IP = %r{
+ (^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})){3}$) | # ip v4
+ (^(
+ (([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}) | # ip v6 not abbreviated
+ (([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4}) | # ip v6 with double colon in the end
+ (([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4}) | # - ip addresses v6
+ (([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4}) | # - with
+ (([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4}) | # - double colon
+ (([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4}) | # - in the middle
+ (([0-9A-Fa-f]{1,4}:){6} ((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3} (\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (([0-9A-Fa-f]{1,4}:){1,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (([0-9A-Fa-f]{1,4}:){1}:([0-9A-Fa-f]{1,4}:){0,4}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (([0-9A-Fa-f]{1,4}:){0,2}:([0-9A-Fa-f]{1,4}:){0,3}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (([0-9A-Fa-f]{1,4}:){0,3}:([0-9A-Fa-f]{1,4}:){0,2}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (([0-9A-Fa-f]{1,4}:){0,4}:([0-9A-Fa-f]{1,4}:){1}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ (::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d) |(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
+ ([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4}) | # ip v6 with compatible to v4
+ (::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4}) | # ip v6 with double colon at the begining
+ (([0-9A-Fa-f]{1,4}:){1,7}:) # ip v6 without ending
+ )$)
+ }x
+
def initialize(env, middleware)
@env = env
@middleware = middleware
@@ -44,25 +72,31 @@ def initialize(env, middleware)
# but will be wrong if the user is behind a proxy. Proxies will set
# HTTP_CLIENT_IP and/or HTTP_X_FORWARDED_FOR, so we prioritize those.
# HTTP_X_FORWARDED_FOR may be a comma-delimited list in the case of
- # multiple chained proxies. The last address which is not a known proxy
- # will be the originating IP.
+ # multiple chained proxies. The first address which is in this list
+ # if it's not a known proxy will be the originating IP.
+ # Format of HTTP_X_FORWARDED_FOR:
+ # client_ip, proxy_ip1, proxy_ip2...
+ # http://en.wikipedia.org/wiki/X-Forwarded-For
def calculate_ip
- client_ip = @env['HTTP_CLIENT_IP']
- forwarded_ips = ips_from('HTTP_X_FORWARDED_FOR')
- remote_addrs = ips_from('REMOTE_ADDR')
+ client_ip = @env['HTTP_CLIENT_IP']
+ forwarded_ip = ips_from('HTTP_X_FORWARDED_FOR').first
+ remote_addrs = ips_from('REMOTE_ADDR')
check_ip = client_ip && @middleware.check_ip
- if check_ip && !forwarded_ips.include?(client_ip)
+ if check_ip && forwarded_ip != client_ip
# We don't know which came from the proxy, and which from the user
raise IpSpoofAttackError, "IP spoofing attack?!" \
"HTTP_CLIENT_IP=#{@env['HTTP_CLIENT_IP'].inspect}" \
"HTTP_X_FORWARDED_FOR=#{@env['HTTP_X_FORWARDED_FOR'].inspect}"
end
- not_proxy = client_ip || forwarded_ips.first || remote_addrs.first
-
- # Return first REMOTE_ADDR if there are no other options
- not_proxy || ips_from('REMOTE_ADDR', :allow_proxies).first
+ client_ips = remove_proxies [client_ip, forwarded_ip, remote_addrs].flatten
+ if client_ips.present?
+ client_ips.first
+ else
+ # If there is no client ip we can return first valid proxy ip from REMOTE_ADDR
+ remote_addrs.find { |ip| valid_ip? ip }
+ end
end
def to_s
@@ -71,12 +105,24 @@ def to_s
@ip = calculate_ip
end
- protected
+ private
- def ips_from(header, allow_proxies = false)
- ips = @env[header] ? @env[header].strip.split(/[,\s]+/) : []
- allow_proxies ? ips : ips.reject{|ip| ip =~ @middleware.proxies }
+ def ips_from(header)
+ @env[header] ? @env[header].strip.split(/[,\s]+/) : []
end
+
+ def valid_ip?(ip)
+ ip =~ VALID_IP
+ end
+
+ def not_a_proxy?(ip)
+ ip !~ @middleware.proxies
+ end
+
+ def remove_proxies(ips)
+ ips.select { |ip| valid_ip?(ip) && not_a_proxy?(ip) }
+ end
+
end
end
View
2  actionpack/lib/action_dispatch/middleware/stack.rb
@@ -110,7 +110,7 @@ def use(*args, &block)
def build(app = nil, &block)
app ||= block
raise "MiddlewareStack#build requires an app" unless app
- middlewares.reverse.inject(app) { |a, e| e.build(a) }
+ middlewares.freeze.reverse.inject(app) { |a, e| e.build(a) }
end
protected
View
35 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/hash/except'
+require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/enumerable'
require 'active_support/inflector'
@@ -58,6 +59,16 @@ def initialize(set, scope, path, options)
@options = (@scope[:options] || {}).merge(options)
@path = normalize_path(path)
normalize_options!
+
+ via_all = @options.delete(:via) if @options[:via] == :all
+
+ if !via_all && request_method_condition.empty?
+ msg = "You should not use the `match` method in your router without specifying an HTTP method.\n" \
+ "If you want to expose your action to GET, use `get` in the router:\n\n" \
+ " Instead of: match \"controller#action\"\n" \
+ " Do: get \"controller#action\""
+ raise msg
+ end
end
def to_route
@@ -244,7 +255,7 @@ def self.normalize_path(path)
end
def self.normalize_name(name)
- normalize_path(name)[1..-1].gsub("/", "_")
+ normalize_path(name)[1..-1].tr("/", "_")
end
module Base
@@ -263,7 +274,7 @@ module Base
# of most Rails applications, this is beneficial.
def root(options = {})
options = { :to => options } if options.is_a?(String)
- match '/', { :as => :root }.merge(options)
+ match '/', { :as => :root, :via => :get }.merge(options)
end
# Matches a url pattern to one or more routes. Any symbols in a pattern
@@ -416,7 +427,7 @@ def mount(app, options = nil)
options[:as] ||= app_name(app)
- match(path, options.merge(:to => app, :anchor => false, :format => false))
+ match(path, options.merge(:to => app, :anchor => false, :format => false, :via => :all))
define_generate_prefix(app, options[:as])
self
@@ -441,7 +452,7 @@ def app_name(app)
app.railtie_name
else
class_name = app.class.is_a?(Class) ? app.name : app.class.name
- ActiveSupport::Inflector.underscore(class_name).gsub("/", "_")
+ ActiveSupport::Inflector.underscore(class_name).tr("/", "_")
end
end
@@ -1294,6 +1305,21 @@ def shallow?
parent_resource.instance_of?(Resource) && @scope[:shallow]
end
+ def draw(name)
+ path = @draw_paths.find do |_path|
+ _path.join("#{name}.rb").file?
+ end
+
+ unless path
+ msg = "Your router tried to #draw the external file #{name}.rb,\n" \
+ "but the file was not found in:\n\n"
+ msg += @draw_paths.map { |_path| " * #{_path}" }.join("\n")
+ raise msg
+ end
+
+ instance_eval(path.join("#{name}.rb").read)
+ end
+
# match 'path' => 'controller#action'
# match 'path', to: 'controller#action'
# match 'path', 'otherpath', on: :member, via: :get
@@ -1543,6 +1569,7 @@ def name_for_action(as, action) #:nodoc:
def initialize(set) #:nodoc:
@set = set
+ @draw_paths = set.draw_paths
@scope = { :path_names => @set.resources_path_names }
end
View
9 actionpack/lib/action_dispatch/routing/redirection.rb
@@ -67,10 +67,13 @@ module Redirection
# params, depending of how many arguments your block accepts. A string is required as a
# return value.
#
- # match 'jokes/:number', :to => redirect do |params, request|
- # path = (params[:number].to_i.even? ? "/wheres-the-beef" : "/i-love-lamp")
+ # match 'jokes/:number', :to => redirect { |params, request|
+ # path = (params[:number].to_i.even? ? "wheres-the-beef" : "i-love-lamp")
# "http://#{request.host_with_port}/#{path}"
- # end
+ # }
+ #
+ # Note that the +do end+ syntax for the redirect block wouldn't work, as Ruby would pass
+ # the block to +match+ instead of +redirect+. Use <tt>{ ... }</tt> instead.
#
# The options version of redirect allows you to supply only the parts of the url which need
# to change, it also supports interpolation of the path similar to the first example.
View
86 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -96,7 +96,25 @@ class NamedRouteCollection #:nodoc:
def initialize
@routes = {}
@helpers = []
- @module = Module.new
+ @module = Module.new do
+ protected
+
+ def handle_positional_args(args, options, route)
+ inner_options = args.extract_options!
+ result = options.dup
+
+ if args.any?
+ keys = route.segment_keys
+ if args.size < keys.size - 1 # take format into account
+ keys -= self.url_options.keys if self.respond_to?(:url_options)
+ keys -= options.keys
+ end
+ result.merge!(Hash[keys.zip(args)])
+ end
+
+ result.merge!(inner_options)
+ end
+ end
end
def helper_names
@@ -135,40 +153,37 @@ def length
end
private
- def url_helper_name(name, kind = :url)
- :"#{name}_#{kind}"
+ def url_helper_name(name, only_path)
+ if only_path
+ :"#{name}_path"
+ else
+ :"#{name}_url"
+ end
end
- def hash_access_name(name, kind = :url)
- :"hash_for_#{name}_#{kind}"
+ def hash_access_name(name, only_path)
+ if only_path
+ :"hash_for_#{name}_path"
+ else
+ :"hash_for_#{name}_url"
+ end
end
def define_named_route_methods(name, route)
- {:url => {:only_path => false}, :path => {:only_path => true}}.each do |kind, opts|
- hash = route.defaults.merge(:use_route => name).merge(opts)
- define_hash_access route, name, kind, hash
- define_url_helper route, name, kind, hash
+ [true, false].each do |only_path|
+ hash = route.defaults.merge(:use_route => name, :only_path => only_path)
+ define_hash_access route, name, hash
+ define_url_helper route, name, hash
end
end
- def define_hash_access(route, name, kind, options)
- selector = hash_access_name(name, kind)
+ def define_hash_access(route, name, options)
+ selector = hash_access_name(name, options[:only_path])
@module.module_eval do
- remove_possible_method selector
-
- define_method(selector) do |*args|
- inner_options = args.extract_options!
- result = options.dup
-
- if args.any?
- result[:_positional_args] = args
- result[:_positional_keys] = route.segment_keys
- end
-
- result.merge(inner_options)
+ redefine_method(selector) do |*args|
+ self.handle_positional_args(args, options, route)
end
-
protected selector
end
helpers << selector
@@ -187,9 +202,9 @@ def define_hash_access(route, name, kind, options)
#
# foo_url(bar, baz, bang, :sort_by => 'baz')
#
- def define_url_helper(route, name, kind, options)
- selector = url_helper_name(name, kind)
- hash_access_method = hash_access_name(name, kind)
+ def define_url_helper(route, name, options)
+ selector = url_helper_name(name, options[:only_path])
+ hash_access_method = hash_access_name(name, options[:only_path])
if optimize_helper?(route)
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
@@ -240,6 +255,7 @@ def optimized_helper(route)
attr_accessor :formatter, :set, :named_routes, :default_scope, :router
attr_accessor :disable_clear_and_finalize, :resources_path_names
attr_accessor :default_url_options, :request_class, :valid_conditions
+ attr_accessor :draw_paths
alias :routes :set
@@ -251,6 +267,7 @@ def initialize(request_class = ActionDispatch::Request)
self.named_routes = NamedRouteCollection.new
self.resources_path_names = self.class.default_resources_path_names.dup
self.default_url_options = {}
+ self.draw_paths = []
self.request_class = request_class
@valid_conditions = {}
@@ -605,10 +622,9 @@ def _generate_prefix(options = {})
nil
end
+ # The +options+ argument must be +nil+ or a hash whose keys are *symbols*.
def url_for(options)
- options = (options || {}).reverse_merge!(default_url_options)
-
- handle_positional_args(options)
+ options = default_url_options.merge(options || {})
user, password = extract_authentication(options)
path_segments = options.delete(:_path_segments)
@@ -679,16 +695,6 @@ def extract_authentication(options)
end
end
- def handle_positional_args(options)
- return unless args = options.delete(:_positional_args)
-
- keys = options.delete(:_positional_keys)
- keys -= options.keys if args.size < keys.size - 1 # take format into account
-
- # Tell url_for to skip default_url_options
- options.merge!(Hash[args.zip(keys).map { |v, k| [k, v] }])
- end
-
end
end
end
View
6 actionpack/lib/action_dispatch/routing/url_for.rb
@@ -144,10 +144,12 @@ def url_options
# # => 'http://somehost.org/tasks/testing?number=33'
def url_for(options = nil)
case options
+ when nil
+ _routes.url_for(url_options.symbolize_keys)
+ when Hash
+ _routes.url_for(options.symbolize_keys.reverse_merge!(url_options))
when String
options
- when nil, Hash
- _routes.url_for((options || {}).symbolize_keys.reverse_merge!(url_options))
else
polymorphic_url(options)
end
View
6 actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -4,11 +4,9 @@ module ActionDispatch
module Assertions
# A small suite of assertions that test responses from \Rails applications.
module ResponseAssertions
- extend ActiveSupport::Concern
-
# Asserts that the response is one of the following types:
#
- # * <tt>:success</tt> - Status code was 200
+ # * <tt>:success</tt> - Status code was in the 200-299 range
# * <tt>:redirect</tt> - Status code was in the 300-399 range
# * <tt>:missing</tt> - Status code was 404
# * <tt>:error</tt> - Status code was in the 500-599 range
@@ -83,7 +81,7 @@ def normalize_argument_to_redirection(fragment)
refer
else
@controller.url_for(fragment)
- end.gsub(/[\0\r\n]/, '')
+ end.delete("\0\r\n")
end
end
end
View
1  actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -269,6 +269,7 @@ def assert_select(*args, &block)
end
end
text.strip! unless NO_STRIP.include?(match.name)
+ text.sub!(/\A\n/, '') if match.name == "textarea"
unless match_with.is_a?(Regexp) ? (text =~ match_with) : (text == match_with.to_s)
content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, text)
true
View
1  actionpack/lib/action_dispatch/testing/test_request.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/hash/indifferent_access'
-require 'active_support/core_ext/hash/reverse_merge'
require 'rack/utils'
module ActionDispatch
View
10 actionpack/lib/action_view/base.rb
@@ -139,7 +139,13 @@ class Base
# How to complete the streaming when an exception occurs.
# This is our best guess: first try to close the attribute, then the tag.
cattr_accessor :streaming_completion_on_exception
- @@streaming_completion_on_exception = %("><script type="text/javascript">window.location = "/500.html"</script></html>)
+ @@streaming_completion_on_exception = %("><script>window.location = "/500.html"</script></html>)
+
+ # Specify whether rendering within namespaced controllers should prefix
+ # the partial paths for ActiveModel objects with the namespace.
+ # (e.g., an Admin::PostsController would render @post using /admin/posts/_post.erb)
+ cattr_accessor :prefix_partial_path_with_controller_namespace
+ @@prefix_partial_path_with_controller_namespace = true
class_attribute :helpers
class_attribute :_routes
@@ -194,7 +200,7 @@ def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:n
# TODO Provide a new API for AV::Base and deprecate this one.
if context.is_a?(ActionView::Renderer)
@view_renderer = context
- elsif
+ else
lookup_context = context.is_a?(ActionView::LookupContext) ?
context : ActionView::LookupContext.new(context)
lookup_context.formats = formats if formats
View
18 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -15,7 +15,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="/images/rails.png?1230601161" />
# stylesheet_link_tag("application")
- # # => <link href="/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# === Using asset hosts
#
@@ -34,7 +34,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="http://assets.example.com/images/rails.png?1230601161" />
# stylesheet_link_tag("application")
- # # => <link href="http://assets.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="http://assets.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# Browsers typically open at most two simultaneous connections to a single
# host, which means your assets often have to wait for other assets to finish
@@ -47,7 +47,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="http://assets0.example.com/images/rails.png?1230601161" />
# stylesheet_link_tag("application")
- # # => <link href="http://assets2.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="http://assets2.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# To do this, you can either setup four actual hosts, or you can use wildcard
# DNS to CNAME the wildcard to a single asset host. You can read more about
@@ -66,7 +66,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="http://assets1.example.com/images/rails.png?1230601161" />
# stylesheet_link_tag("application")
- # # => <link href="http://assets2.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="http://assets2.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# The example above generates "http://assets1.example.com" and
# "http://assets2.example.com". This option is useful for example if
@@ -86,7 +86,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="http://images.example.com/images/rails.png?1230601161" />
# stylesheet_link_tag("application")
- # # => <link href="http://assets.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="http://assets.example.com/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# Alternatively you may ask for a second parameter +request+. That one is
# particularly useful for serving assets from an SSL-protected page. The
@@ -163,7 +163,7 @@ module Helpers #:nodoc:
# image_tag("rails.png")
# # => <img alt="Rails" src="/release-12345/images/rails.png" />
# stylesheet_link_tag("application")
- # # => <link href="/release-12345/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
+ # # => <link href="/release-12345/stylesheets/application.css?1232285206" media="screen" rel="stylesheet" />
#
# Changing the asset_path does require that your web servers have
# knowledge of the asset template paths that you rewrite to so it's not
@@ -385,7 +385,7 @@ def font_url(source)
# image_tag("mouse.png", :mouseover => image_path("mouse_over.png")) # =>
# <img src="/images/mouse.png" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" alt="Mouse" />
def image_tag(source, options={})
- options = options.dup.symbolize_keys!
+ options = options.symbolize_keys
src = options[:src] = path_to_image(source)
@@ -442,7 +442,7 @@ def image_alt(src)
# <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
# video_tag(["trailer.ogg", "trailer.flv"]) # =>
# <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
- # video_tag(["trailer.ogg", "trailer.flv"] :size => "160x120") # =>
+ # video_tag(["trailer.ogg", "trailer.flv"], :size => "160x120") # =>
# <video height="120" width="160"><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
def video_tag(*sources)
multiple_sources_tag('video', sources) do |options|
@@ -478,7 +478,7 @@ def asset_paths
end
def multiple_sources_tag(type, sources)
- options = sources.extract_options!.dup.symbolize_keys!
+ options = sources.extract_options!.symbolize_keys
sources.flatten!
yield options if block_given?
View
56 actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
@@ -16,7 +16,7 @@ def extension
end
def asset_tag(source, options)
- content_tag("script", "", { "type" => Mime::JS, "src" => path_to_asset(source) }.merge(options))
+ content_tag("script", "", { "src" => path_to_asset(source) }.merge(options))
end
def custom_dir
@@ -60,9 +60,9 @@ module ClassMethods
# ActionView::Helpers::AssetTagHelper.register_javascript_expansion :monkey => ["head", "body", "tail"]
#
# javascript_include_tag :monkey # =>
- # <script type="text/javascript" src="/javascripts/head.js"></script>
- # <script type="text/javascript" src="/javascripts/body.js"></script>
- # <script type="text/javascript" src="/javascripts/tail.js"></script>
+ # <script src="/javascripts/head.js"></script>
+ # <script src="/javascripts/body.js"></script>
+ # <script src="/javascripts/tail.js"></script>
def register_javascript_expansion(expansions)
js_expansions = JavascriptIncludeTag.expansions
expansions.each do |key, values|
@@ -116,36 +116,36 @@ def javascript_url(source)
#
# ==== Examples
# javascript_include_tag "xmlhr"
- # # => <script type="text/javascript" src="/javascripts/xmlhr.js?1284139606"></script>
+ # # => <script src="/javascripts/xmlhr.js?1284139606"></script>
#
# javascript_include_tag "xmlhr.js"
- # # => <script type="text/javascript" src="/javascripts/xmlhr.js?1284139606"></script>
+ # # => <script src="/javascripts/xmlhr.js?1284139606"></script>
#
# javascript_include_tag "common.javascript", "/elsewhere/cools"
- # # => <script type="text/javascript" src="/javascripts/common.javascript?1284139606"></script>
- # # <script type="text/javascript" src="/elsewhere/cools.js?1423139606"></script>
+ # # => <script src="/javascripts/common.javascript?1284139606"></script>
+ # # <script src="/elsewhere/cools.js?1423139606"></script>
#
# javascript_include_tag "http://www.example.com/xmlhr"
- # # => <script type="text/javascript" src="http://www.example.com/xmlhr"></script>
+ # # => <script src="http://www.example.com/xmlhr"></script>
#
# javascript_include_tag "http://www.example.com/xmlhr.js"
- # # => <script type="text/javascript" src="http://www.example.com/xmlhr.js"></script>
+ # # => <script src="http://www.example.com/xmlhr.js"></script>
#
# javascript_include_tag :defaults
- # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
+ # # => <script src="/javascripts/jquery.js?1284139606"></script>
+ # # <script src="/javascripts/rails.js?1284139606"></script>
+ # # <script src="/javascripts/application.js?1284139606"></script>
#
# * = The application.js file is only referenced if it exists
#
# You can also include all JavaScripts in the +javascripts+ directory using <tt>:all</tt> as the source:
#
# javascript_include_tag :all
- # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script>
+ # # => <script src="/javascripts/jquery.js?1284139606"></script>
+ # # <script src="/javascripts/rails.js?1284139606"></script>
+ # # <script src="/javascripts/application.js?1284139606"></script>
+ # # <script src="/javascripts/shop.js?1284139606"></script>
+ # # <script src="/javascripts/checkout.js?1284139606"></script>
#
# Note that your defaults of choice will be included first, so they will be available to all subsequently
# included files.
@@ -166,25 +166,25 @@ def javascript_url(source)
#
# # assuming config.perform_caching is false
# javascript_include_tag :all, :cache => true
- # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/shop.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/checkout.js?1284139606"></script>
+ # # => <script src="/javascripts/jquery.js?1284139606"></script>
+ # # <script src="/javascripts/rails.js?1284139606"></script>
+ # # <script src="/javascripts/application.js?1284139606"></script>
+ # # <script src="/javascripts/shop.js?1284139606"></script>
+ # # <script src="/javascripts/checkout.js?1284139606"></script>
#
# # assuming config.perform_caching is true
# javascript_include_tag :all, :cache => true
- # # => <script type="text/javascript" src="/javascripts/all.js?1344139789"></script>
+ # # => <script src="/javascripts/all.js?1344139789"></script>
#
# # assuming config.perform_caching is false
# javascript_include_tag "jquery", "cart", "checkout", :cache => "shop"
- # # => <script type="text/javascript" src="/javascripts/jquery.js?1284139606"></script>
- # # <script type="text/javascript" src="/javascripts/cart.js?1289139157"></script>
- # # <script type="text/javascript" src="/javascripts/checkout.js?1299139816"></script>
+ # # => <script src="/javascripts/jquery.js?1284139606"></script>
+ # # <script src="/javascripts/cart.js?1289139157"></script>
+ # # <script src="/javascripts/checkout.js?1299139816"></script>
#
# # assuming config.perform_caching is true
# javascript_include_tag "jquery", "cart", "checkout", :cache => "shop"
- # # => <script type="text/javascript" src="/javascripts/shop.js?1299139816"></script>
+ # # => <script src="/javascripts/shop.js?1299139816"></script>
#
# The <tt>:recursive</tt> option is also available for caching:
#
View
46 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
@@ -17,7 +17,7 @@ def extension
def asset_tag(source, options)
# We force the :request protocol here to avoid a double-download bug in IE7 and IE8
- tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => path_to_asset(source, :protocol => :request) }.merge(options))
+ tag("link", { "rel" => "stylesheet", "media" => "screen", "href" => path_to_asset(source, :protocol => :request) }.merge(options))
end
def custom_dir
@@ -38,9 +38,9 @@ module ClassMethods
# ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :monkey => ["head", "body", "tail"]
#
# stylesheet_link_tag :monkey # =>
- # <link href="/stylesheets/head.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/body.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/head.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/body.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/tail.css" media="screen" rel="stylesheet" />
def register_stylesheet_expansion(expansions)
style_expansions = StylesheetIncludeTag.expansions
expansions.each do |key, values|
@@ -81,30 +81,30 @@ def stylesheet_url(source)
#
# ==== Examples
# stylesheet_link_tag "style" # =>
- # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag "style.css" # =>
- # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag "http://www.example.com/style.css" # =>
- # <link href="http://www.example.com/style.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="http://www.example.com/style.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag "style", :media => "all" # =>
- # <link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style.css" media="all" rel="stylesheet" />
#
# stylesheet_link_tag "style", :media => "print" # =>
- # <link href="/stylesheets/style.css" media="print" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style.css" media="print" rel="stylesheet" />
#
# stylesheet_link_tag "random.styles", "/css/stylish" # =>
- # <link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/random.styles" media="screen" rel="stylesheet" />
+ # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
#
# You can also include all styles in the stylesheets directory using <tt>:all</tt> as the source:
#
# stylesheet_link_tag :all # =>
- # <link href="/stylesheets/style1.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/styleB.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/styleX2.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style1.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/styleB.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/styleX2.css" media="screen" rel="stylesheet" />
#
# If you want Rails to search in all the subdirectories under stylesheets, you should explicitly set <tt>:recursive</tt>:
#
@@ -113,26 +113,26 @@ def stylesheet_url(source)
# == Caching multiple stylesheets into one
#
# You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be
- # compressed by gzip (leading to faster transfers). Caching will only happen if config.perform_caching
+ # compressed by gzip (leading to faster transfers). Caching will only happen if +config.perform_caching+
# is set to true (which is the case by default for the Rails production environment, but not for the development
# environment). Examples:
#
# ==== Examples
# stylesheet_link_tag :all, :cache => true # when config.perform_caching is false =>
- # <link href="/stylesheets/style1.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/styleB.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/styleX2.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/style1.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/styleB.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/styleX2.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag :all, :cache => true # when config.perform_caching is true =>
- # <link href="/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/all.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when config.perform_caching is false =>
- # <link href="/stylesheets/shop.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/cart.css" media="screen" rel="stylesheet" type="text/css" />
- # <link href="/stylesheets/checkout.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/shop.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/cart.css" media="screen" rel="stylesheet" />
+ # <link href="/stylesheets/checkout.css" media="screen" rel="stylesheet" />
#
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when config.perform_caching is true =>
- # <link href="/stylesheets/payment.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="/stylesheets/payment.css" media="screen" rel="stylesheet" />
#
# The <tt>:recursive</tt> option is also available for caching:
#
View
5 actionpack/lib/action_view/helpers/atom_feed_helper.rb
@@ -176,6 +176,7 @@ def updated(date_or_time = nil)
# * <tt>:updated</tt>: Time of update. Defaults to the updated_at attribute on the record if one such exists.
# * <tt>:url</tt>: The URL for this entry. Defaults to the polymorphic_url for the record.
# * <tt>:id</tt>: The ID for this entry. Defaults to "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}"
+ # * <tt>:type</tt>: The TYPE for this entry. Defaults to "text/html".
def entry(record, options = {})
@xml.entry do
@xml.id(options[:id] || "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}")
@@ -188,7 +189,9 @@ def entry(record, options = {})
@xml.updated((options[:updated] || record.updated_at).xmlschema)
end
- @xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record))
+ type = options.fetch(:type, 'text/html')
+
+ @xml.link(:rel => 'alternate', :type => type, :href => options[:url] || @view.polymorphic_url(record))
yield AtomBuilder.new(@xml)
end
View
2  actionpack/lib/action_view/helpers/capture_helper.rb
@@ -96,7 +96,7 @@ def capture(*args)
# Please login!
#
# <% content_for :script do %>
- # <script type="text/javascript">alert('You are not authorized to view this page!')</script>
+ # <script>alert('You are not authorized to view this page!')</script>
# <% end %>
#
# Then, in another view, you could to do something like this:
View
42 actionpack/lib/action_view/helpers/date_helper.rb
@@ -12,11 +12,11 @@ module Helpers
# elements. All of the select-type methods share a number of common options that are as follows:
#
# * <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday"
- # would give birthday[month] instead of date[month] if passed to the <tt>select_month</tt> method.
+ # would give \birthday[month] instead of \date[month] if passed to the <tt>select_month</tt> method.
# * <tt>:include_blank</tt> - set to true if it should be possible to set an empty date.
# * <tt>:discard_type</tt> - set to true if you want to discard the type part of the select name. If set to true,
# the <tt>select_month</tt> method would use simply "date" (which can be overwritten using <tt>:prefix</tt>) instead
- # of "date[month]".
+ # of \date[month].
module DateHelper
# Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
# Set <tt>include_seconds</tt> to true if you want more detailed approximations when distance < 1 min, 29 secs.
@@ -64,11 +64,15 @@ module DateHelper
# distance_of_time_in_words(to_time, from_time, true) # => about 6 years
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
#
+ # distance_of_time_in_words(70) # => 1 minute
+ # distance_of_time_in_words(60*60) # => about 1 hour
+ #
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
- distance_in_minutes = (((to_time - from_time).abs)/60).round
- distance_in_seconds = ((to_time - from_time).abs).round
+ from_time, to_time = to_time, from_time if from_time > to_time
+ distance_in_minutes = ((to_time - from_time)/60.0).round
+ distance_in_seconds = (to_time - from_time).round
I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
case distance_in_minutes
@@ -94,18 +98,22 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, o
when 43200..86399 then locale.t :about_x_months, :count => 1
when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
else
- fyear = from_time.year
- fyear += 1 if from_time.month >= 3
- tyear = to_time.year
- tyear -= 1 if to_time.month < 3
- leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)}
- minute_offset_for_leap_year = leap_years * 1440
- # Discount the leap year days when calculating year distance.
- # e.g. if there are 20 leap year days between 2 dates having the same day
- # and month then the based on 365 days calculation
- # the distance in years will come out to over 80 years when in written
- # english it would read better as about 80 years.
- minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
+ if from_time.acts_like?(:time) && to_time.acts_like?(:time)
+ fyear = from_time.year
+ fyear += 1 if from_time.month >= 3
+ tyear = to_time.year
+ tyear -= 1 if to_time.month < 3
+ leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)}
+ minute_offset_for_leap_year = leap_years * 1440
+ # Discount the leap year days when calculating year distance.
+ # e.g. if there are 20 leap year days between 2 dates having the same day
+ # and month then the based on 365 days calculation
+ # the distance in years will come out to over 80 years when in written
+ # english it would read better as about 80 years.
+ minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
+ else
+ minutes_with_offset = distance_in_minutes
+ end
remainder = (minutes_with_offset % 525600)
distance_in_years = (minutes_with_offset / 525600)
if remainder < 131400
@@ -795,7 +803,7 @@ def select_year
private
%w( sec min hour day month year ).each do |method|
define_method(method) do
- @datetime.kind_of?(Fixnum) ? @datetime : @datetime.send(method) if @datetime
+ @datetime.kind_of?(Numeric) ? @datetime : @datetime.send(method) if @datetime
end
end
View
31 actionpack/lib/action_view/helpers/form_helper.rb
@@ -184,7 +184,7 @@ def convert_to_model(object)
# First name: <%= f.text_field :first_name %>
# Last name : <%= f.text_field :last_name %>
# Biography : <%= text_area :person, :biography %>
- # Admin? : <%= check_box_tag "person[admin]", @person.company.admin? %>
+ # Admin? : <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
# <%= f.submit %>
# <% end %>
#
@@ -673,6 +673,19 @@ def apply_form_for_options!(record, object, options) #:nodoc:
# <% end %>