rails 2.2.3 → 2.3.2

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

Potentially problematic release.


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

Files changed (229) hide show
  1. data/CHANGELOG +272 -191
  2. data/MIT-LICENSE +1 -1
  3. data/README +6 -19
  4. data/Rakefile +24 -71
  5. data/bin/rails +1 -0
  6. data/builtin/rails_info/rails/info.rb +12 -8
  7. data/configs/databases/mysql.yml +3 -0
  8. data/configs/initializers/backtrace_silencers.rb +7 -0
  9. data/configs/initializers/new_rails_defaults.rb +2 -0
  10. data/configs/initializers/session_store.rb +15 -0
  11. data/dispatches/config.ru +7 -0
  12. data/doc/README_FOR_APP +2 -5
  13. data/environments/boot.rb +1 -0
  14. data/environments/environment.rb +14 -48
  15. data/environments/production.rb +11 -7
  16. data/environments/test.rb +6 -0
  17. data/helpers/application_controller.rb +10 -0
  18. data/helpers/test_helper.rb +1 -1
  19. data/html/500.html +0 -3
  20. data/html/index.html +1 -0
  21. data/lib/commands/about.rb +1 -1
  22. data/lib/commands/dbconsole.rb +18 -2
  23. data/lib/commands/plugin.rb +4 -3
  24. data/lib/commands/runner.rb +13 -7
  25. data/lib/commands/server.rb +98 -33
  26. data/lib/console_app.rb +4 -4
  27. data/lib/console_with_helpers.rb +2 -23
  28. data/lib/dispatcher.rb +1 -1
  29. data/lib/fcgi_handler.rb +12 -10
  30. data/lib/initializer.rb +108 -41
  31. data/lib/rails/backtrace_cleaner.rb +54 -0
  32. data/lib/rails/gem_dependency.rb +124 -94
  33. data/lib/rails/plugin.rb +49 -6
  34. data/lib/rails/plugin/loader.rb +66 -27
  35. data/lib/rails/plugin/locator.rb +1 -1
  36. data/lib/rails/rack.rb +3 -1
  37. data/lib/rails/rack/debugger.rb +21 -0
  38. data/lib/rails/rack/log_tailer.rb +35 -0
  39. data/lib/rails/rack/metal.rb +51 -0
  40. data/lib/rails/rack/static.rb +15 -4
  41. data/lib/rails/version.rb +2 -2
  42. data/lib/rails_generator/base.rb +3 -0
  43. data/lib/rails_generator/commands.rb +8 -3
  44. data/lib/rails_generator/generators/applications/app/app_generator.rb +210 -136
  45. data/lib/rails_generator/generators/applications/app/scm/git.rb +16 -0
  46. data/lib/rails_generator/generators/applications/app/scm/scm.rb +8 -0
  47. data/lib/rails_generator/generators/applications/app/scm/svn.rb +7 -0
  48. data/lib/rails_generator/generators/applications/app/template_runner.rb +401 -0
  49. data/lib/rails_generator/generators/components/controller/USAGE +12 -11
  50. data/lib/rails_generator/generators/components/controller/controller_generator.rb +7 -1
  51. data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +4 -0
  52. data/lib/rails_generator/generators/components/helper/USAGE +24 -0
  53. data/lib/rails_generator/generators/components/helper/helper_generator.rb +25 -0
  54. data/lib/rails_generator/generators/components/helper/templates/helper.rb +2 -0
  55. data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +4 -0
  56. data/lib/rails_generator/generators/components/metal/USAGE +8 -0
  57. data/lib/rails_generator/generators/components/metal/metal_generator.rb +8 -0
  58. data/lib/rails_generator/generators/components/metal/templates/metal.rb +12 -0
  59. data/lib/rails_generator/generators/components/resource/USAGE +2 -2
  60. data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -0
  61. data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +4 -0
  62. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +2 -0
  63. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
  64. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +4 -4
  65. data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +4 -0
  66. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +1 -1
  67. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +2 -2
  68. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +2 -2
  69. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +2 -2
  70. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +1 -1
  71. data/lib/rails_generator/secret_key_generator.rb +2 -0
  72. data/lib/tasks/databases.rake +13 -6
  73. data/lib/tasks/documentation.rake +2 -9
  74. data/lib/tasks/framework.rake +26 -1
  75. data/lib/tasks/gems.rake +33 -48
  76. data/lib/tasks/middleware.rake +7 -0
  77. data/lib/tasks/misc.rake +7 -0
  78. data/lib/tasks/statistics.rake +0 -1
  79. data/lib/tasks/testing.rake +5 -5
  80. data/lib/tasks/tmp.rake +2 -2
  81. data/lib/test_help.rb +16 -8
  82. metadata +92 -159
  83. data/bin/performance/request +0 -3
  84. data/bin/process/inspector +0 -3
  85. data/bin/process/reaper +0 -3
  86. data/bin/process/spawner +0 -3
  87. data/config.ru +0 -17
  88. data/configs/apache.conf +0 -40
  89. data/configs/lighttpd.conf +0 -54
  90. data/doc/guides/html/2_2_release_notes.html +0 -1185
  91. data/doc/guides/html/actioncontroller_basics.html +0 -1270
  92. data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
  93. data/doc/guides/html/association_basics.html +0 -2585
  94. data/doc/guides/html/authors.html +0 -240
  95. data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
  96. data/doc/guides/html/caching_with_rails.html +0 -583
  97. data/doc/guides/html/command_line.html +0 -434
  98. data/doc/guides/html/configuring.html +0 -438
  99. data/doc/guides/html/creating_plugins.html +0 -1594
  100. data/doc/guides/html/debugging_rails_applications.html +0 -1175
  101. data/doc/guides/html/finders.html +0 -1090
  102. data/doc/guides/html/form_helpers.html +0 -638
  103. data/doc/guides/html/getting_started_with_rails.html +0 -2066
  104. data/doc/guides/html/index.html +0 -349
  105. data/doc/guides/html/layouts_and_rendering.html +0 -1406
  106. data/doc/guides/html/migrations.html +0 -921
  107. data/doc/guides/html/routing_outside_in.html +0 -2213
  108. data/doc/guides/html/security.html +0 -1346
  109. data/doc/guides/html/testing_rails_applications.html +0 -1859
  110. data/doc/guides/source/2_2_release_notes.txt +0 -435
  111. data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
  112. data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
  113. data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
  114. data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
  115. data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
  116. data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
  117. data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
  118. data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
  119. data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
  120. data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
  121. data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
  122. data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
  123. data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
  124. data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
  125. data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
  126. data/doc/guides/source/active_record_basics.txt +0 -181
  127. data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
  128. data/doc/guides/source/association_basics.txt +0 -1840
  129. data/doc/guides/source/authors.txt +0 -39
  130. data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
  131. data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
  132. data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
  133. data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
  134. data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
  135. data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
  136. data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
  137. data/doc/guides/source/caching_with_rails.txt +0 -367
  138. data/doc/guides/source/command_line.txt +0 -147
  139. data/doc/guides/source/configuring.txt +0 -225
  140. data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
  141. data/doc/guides/source/creating_plugins/appendix.txt +0 -46
  142. data/doc/guides/source/creating_plugins/controllers.txt +0 -59
  143. data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
  144. data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
  145. data/doc/guides/source/creating_plugins/gem.txt +0 -1
  146. data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
  147. data/doc/guides/source/creating_plugins/helpers.txt +0 -51
  148. data/doc/guides/source/creating_plugins/index.txt +0 -52
  149. data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
  150. data/doc/guides/source/creating_plugins/models.txt +0 -76
  151. data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
  152. data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
  153. data/doc/guides/source/debugging_rails_applications.txt +0 -733
  154. data/doc/guides/source/finders.txt +0 -668
  155. data/doc/guides/source/form_helpers.txt +0 -345
  156. data/doc/guides/source/getting_started_with_rails.txt +0 -1256
  157. data/doc/guides/source/images/belongs_to.png +0 -0
  158. data/doc/guides/source/images/bullet.gif +0 -0
  159. data/doc/guides/source/images/csrf.png +0 -0
  160. data/doc/guides/source/images/habtm.png +0 -0
  161. data/doc/guides/source/images/has_many.png +0 -0
  162. data/doc/guides/source/images/has_many_through.png +0 -0
  163. data/doc/guides/source/images/has_one.png +0 -0
  164. data/doc/guides/source/images/has_one_through.png +0 -0
  165. data/doc/guides/source/images/header_backdrop.png +0 -0
  166. data/doc/guides/source/images/icons/README +0 -5
  167. data/doc/guides/source/images/icons/callouts/1.png +0 -0
  168. data/doc/guides/source/images/icons/callouts/10.png +0 -0
  169. data/doc/guides/source/images/icons/callouts/11.png +0 -0
  170. data/doc/guides/source/images/icons/callouts/12.png +0 -0
  171. data/doc/guides/source/images/icons/callouts/13.png +0 -0
  172. data/doc/guides/source/images/icons/callouts/14.png +0 -0
  173. data/doc/guides/source/images/icons/callouts/15.png +0 -0
  174. data/doc/guides/source/images/icons/callouts/2.png +0 -0
  175. data/doc/guides/source/images/icons/callouts/3.png +0 -0
  176. data/doc/guides/source/images/icons/callouts/4.png +0 -0
  177. data/doc/guides/source/images/icons/callouts/5.png +0 -0
  178. data/doc/guides/source/images/icons/callouts/6.png +0 -0
  179. data/doc/guides/source/images/icons/callouts/7.png +0 -0
  180. data/doc/guides/source/images/icons/callouts/8.png +0 -0
  181. data/doc/guides/source/images/icons/callouts/9.png +0 -0
  182. data/doc/guides/source/images/icons/caution.png +0 -0
  183. data/doc/guides/source/images/icons/example.png +0 -0
  184. data/doc/guides/source/images/icons/home.png +0 -0
  185. data/doc/guides/source/images/icons/important.png +0 -0
  186. data/doc/guides/source/images/icons/next.png +0 -0
  187. data/doc/guides/source/images/icons/note.png +0 -0
  188. data/doc/guides/source/images/icons/prev.png +0 -0
  189. data/doc/guides/source/images/icons/tip.png +0 -0
  190. data/doc/guides/source/images/icons/up.png +0 -0
  191. data/doc/guides/source/images/icons/warning.png +0 -0
  192. data/doc/guides/source/images/polymorphic.png +0 -0
  193. data/doc/guides/source/images/rails_logo_remix.gif +0 -0
  194. data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
  195. data/doc/guides/source/images/session_fixation.png +0 -0
  196. data/doc/guides/source/index.txt +0 -118
  197. data/doc/guides/source/layouts_and_rendering.txt +0 -982
  198. data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
  199. data/doc/guides/source/migrations/changelog.txt +0 -5
  200. data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
  201. data/doc/guides/source/migrations/foreign_keys.txt +0 -8
  202. data/doc/guides/source/migrations/index.txt +0 -22
  203. data/doc/guides/source/migrations/rakeing_around.txt +0 -111
  204. data/doc/guides/source/migrations/scheming.txt +0 -47
  205. data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
  206. data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
  207. data/doc/guides/source/routing_outside_in.txt +0 -986
  208. data/doc/guides/source/security.txt +0 -984
  209. data/doc/guides/source/stylesheets/base.css +0 -358
  210. data/doc/guides/source/stylesheets/forms.css +0 -35
  211. data/doc/guides/source/stylesheets/more.css +0 -82
  212. data/doc/guides/source/templates/guides.html.erb +0 -97
  213. data/doc/guides/source/templates/inline.css +0 -165
  214. data/doc/guides/source/testing_rails_applications.txt +0 -995
  215. data/helpers/application.rb +0 -15
  216. data/lib/commands/performance/request.rb +0 -6
  217. data/lib/commands/process/inspector.rb +0 -68
  218. data/lib/commands/process/reaper.rb +0 -149
  219. data/lib/commands/process/spawner.rb +0 -219
  220. data/lib/commands/process/spinner.rb +0 -57
  221. data/lib/commands/servers/base.rb +0 -31
  222. data/lib/commands/servers/lighttpd.rb +0 -94
  223. data/lib/commands/servers/mongrel.rb +0 -69
  224. data/lib/commands/servers/new_mongrel.rb +0 -16
  225. data/lib/commands/servers/thin.rb +0 -25
  226. data/lib/commands/servers/webrick.rb +0 -66
  227. data/lib/rails/mongrel_server/commands.rb +0 -342
  228. data/lib/rails/mongrel_server/handler.rb +0 -55
  229. data/lib/rails/rack/logger.rb +0 -28
@@ -1,225 +0,0 @@
1
- Configuring Rails Applications
2
- ==============================
3
-
4
- This guide covers the configuration and initialization features available to Rails applications. By referring to this guide, you will be able to:
5
-
6
- * Adjust the behavior of your Rails applications
7
- * Add additional code to be run at application start time
8
-
9
- == Locations for Initialization Code
10
-
11
- preinitializers
12
- environment.rb first
13
- env-specific files
14
- initializers (load_application_initializers)
15
- after-initializer
16
-
17
- == Using a Preinitializer
18
-
19
- == Configuring Rails Components
20
-
21
- === Configuring Active Record
22
-
23
- === Configuring Action Controller
24
-
25
- === Configuring Action View
26
-
27
- === Configuring Action Mailer
28
-
29
- === Configuring Active Resource
30
-
31
- === Configuring Active Support
32
-
33
- == Using Initializers
34
- organization, controlling load order
35
-
36
- == Using an After-Initializer
37
-
38
- == Changelog ==
39
-
40
- http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/28[Lighthouse ticket]
41
-
42
- * November 5, 2008: Rough outline by link:../authors.html#mgunderloy[Mike Gunderloy]
43
-
44
-
45
- actionmailer/lib/action_mailer/base.rb
46
- 257: cattr_accessor :logger
47
- 267: cattr_accessor :smtp_settings
48
- 273: cattr_accessor :sendmail_settings
49
- 276: cattr_accessor :raise_delivery_errors
50
- 282: cattr_accessor :perform_deliveries
51
- 285: cattr_accessor :deliveries
52
- 288: cattr_accessor :default_charset
53
- 291: cattr_accessor :default_content_type
54
- 294: cattr_accessor :default_mime_version
55
- 297: cattr_accessor :default_implicit_parts_order
56
- 299: cattr_reader :protected_instance_variables
57
-
58
- actionmailer/Rakefile
59
- 36: rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
60
-
61
- actionpack/lib/action_controller/base.rb
62
- 263: cattr_reader :protected_instance_variables
63
- 273: cattr_accessor :asset_host
64
- 279: cattr_accessor :consider_all_requests_local
65
- 285: cattr_accessor :allow_concurrency
66
- 317: cattr_accessor :param_parsers
67
- 321: cattr_accessor :default_charset
68
- 325: cattr_accessor :logger
69
- 329: cattr_accessor :resource_action_separator
70
- 333: cattr_accessor :resources_path_names
71
- 337: cattr_accessor :request_forgery_protection_token
72
- 341: cattr_accessor :optimise_named_routes
73
- 351: cattr_accessor :use_accept_header
74
- 361: cattr_accessor :relative_url_root
75
-
76
- actionpack/lib/action_controller/caching/pages.rb
77
- 55: cattr_accessor :page_cache_directory
78
- 58: cattr_accessor :page_cache_extension
79
-
80
- actionpack/lib/action_controller/caching.rb
81
- 37: cattr_reader :cache_store
82
- 48: cattr_accessor :perform_caching
83
-
84
- actionpack/lib/action_controller/dispatcher.rb
85
- 98: cattr_accessor :error_file_path
86
-
87
- actionpack/lib/action_controller/mime_type.rb
88
- 24: cattr_reader :html_types, :unverifiable_types
89
-
90
- actionpack/lib/action_controller/rescue.rb
91
- 36: base.cattr_accessor :rescue_responses
92
- 40: base.cattr_accessor :rescue_templates
93
-
94
- actionpack/lib/action_controller/session/active_record_store.rb
95
- 60: cattr_accessor :data_column_name
96
- 170: cattr_accessor :connection
97
- 173: cattr_accessor :table_name
98
- 177: cattr_accessor :session_id_column
99
- 181: cattr_accessor :data_column
100
- 282: cattr_accessor :session_class
101
-
102
- actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
103
- 44: cattr_accessor :included_tags, :instance_writer => false
104
-
105
- actionpack/lib/action_view/base.rb
106
- 189: cattr_accessor :debug_rjs
107
- 193: cattr_accessor :warn_cache_misses
108
-
109
- actionpack/lib/action_view/helpers/active_record_helper.rb
110
- 7: cattr_accessor :field_error_proc
111
-
112
- actionpack/lib/action_view/helpers/form_helper.rb
113
- 805: cattr_accessor :default_form_builder
114
-
115
- actionpack/lib/action_view/template_handlers/erb.rb
116
- 47: cattr_accessor :erb_trim_mode
117
-
118
- actionpack/test/active_record_unit.rb
119
- 5: cattr_accessor :able_to_connect
120
- 6: cattr_accessor :connected
121
-
122
- actionpack/test/controller/filters_test.rb
123
- 286: cattr_accessor :execution_log
124
-
125
- actionpack/test/template/form_options_helper_test.rb
126
- 3:TZInfo::Timezone.cattr_reader :loaded_zones
127
-
128
- activemodel/lib/active_model/errors.rb
129
- 28: cattr_accessor :default_error_messages
130
-
131
- activemodel/Rakefile
132
- 19: rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
133
-
134
- activerecord/lib/active_record/attribute_methods.rb
135
- 9: base.cattr_accessor :attribute_types_cached_by_default, :instance_writer => false
136
- 11: base.cattr_accessor :time_zone_aware_attributes, :instance_writer => false
137
-
138
- activerecord/lib/active_record/base.rb
139
- 394: cattr_accessor :logger, :instance_writer => false
140
- 443: cattr_accessor :configurations, :instance_writer => false
141
- 450: cattr_accessor :primary_key_prefix_type, :instance_writer => false
142
- 456: cattr_accessor :table_name_prefix, :instance_writer => false
143
- 461: cattr_accessor :table_name_suffix, :instance_writer => false
144
- 467: cattr_accessor :pluralize_table_names, :instance_writer => false
145
- 473: cattr_accessor :colorize_logging, :instance_writer => false
146
- 478: cattr_accessor :default_timezone, :instance_writer => false
147
- 487: cattr_accessor :schema_format , :instance_writer => false
148
- 491: cattr_accessor :timestamped_migrations , :instance_writer => false
149
-
150
- activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
151
- 11: cattr_accessor :connection_handler, :instance_writer => false
152
-
153
- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
154
- 166: cattr_accessor :emulate_booleans
155
-
156
- activerecord/lib/active_record/fixtures.rb
157
- 498: cattr_accessor :all_loaded_fixtures
158
-
159
- activerecord/lib/active_record/locking/optimistic.rb
160
- 38: base.cattr_accessor :lock_optimistically, :instance_writer => false
161
-
162
- activerecord/lib/active_record/migration.rb
163
- 259: cattr_accessor :verbose
164
-
165
- activerecord/lib/active_record/schema_dumper.rb
166
- 13: cattr_accessor :ignore_tables
167
-
168
- activerecord/lib/active_record/serializers/json_serializer.rb
169
- 4: base.cattr_accessor :include_root_in_json, :instance_writer => false
170
-
171
- activerecord/Rakefile
172
- 142: rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
173
-
174
- activerecord/test/cases/lifecycle_test.rb
175
- 61: cattr_reader :last_inherited
176
-
177
- activerecord/test/cases/mixin_test.rb
178
- 9: cattr_accessor :forced_now_time
179
-
180
- activeresource/lib/active_resource/base.rb
181
- 206: cattr_accessor :logger
182
-
183
- activeresource/Rakefile
184
- 43: rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
185
-
186
- activesupport/lib/active_support/buffered_logger.rb
187
- 17: cattr_accessor :silencer
188
-
189
- activesupport/lib/active_support/cache.rb
190
- 81: cattr_accessor :logger
191
-
192
- activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
193
- 5:# cattr_accessor :hair_colors
194
- 10: def cattr_reader(*syms)
195
- 29: def cattr_writer(*syms)
196
- 50: def cattr_accessor(*syms)
197
- 51: cattr_reader(*syms)
198
- 52: cattr_writer(*syms)
199
-
200
- activesupport/lib/active_support/core_ext/logger.rb
201
- 34: cattr_accessor :silencer
202
-
203
- activesupport/test/core_ext/class/attribute_accessor_test.rb
204
- 6: cattr_accessor :foo
205
- 7: cattr_accessor :bar, :instance_writer => false
206
-
207
- activesupport/test/core_ext/module/synchronization_test.rb
208
- 6: @target.cattr_accessor :mutex, :instance_writer => false
209
-
210
- railties/doc/guides/html/creating_plugins.html
211
- 786: cattr_accessor <span style="color: #990000">:</span>yaffle_text_field<span style="color: #990000">,</span> <span style="color: #990000">:</span>yaffle_date_field
212
- 860: cattr_accessor <span style="color: #990000">:</span>yaffle_text_field<span style="color: #990000">,</span> <span style="color: #990000">:</span>yaffle_date_field
213
-
214
- railties/lib/rails_generator/base.rb
215
- 93: cattr_accessor :logger
216
-
217
- railties/Rakefile
218
- 265: rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
219
-
220
- railties/test/rails_info_controller_test.rb
221
- 12: cattr_accessor :local_request
222
-
223
- Rakefile
224
- 32: rdoc.options << '-A cattr_accessor=object'
225
-
@@ -1,191 +0,0 @@
1
- == Add an `acts_as_yaffle` method to Active Record ==
2
-
3
- A common pattern in plugins is to add a method called 'acts_as_something' to models. In this case, you want to write a method called 'acts_as_yaffle' that adds a 'squawk' method to your models.
4
-
5
- To begin, set up your files so that you have:
6
-
7
- *vendor/plugins/yaffle/test/acts_as_yaffle_test.rb*
8
-
9
- [source, ruby]
10
- ------------------------------------------------------
11
- require File.dirname(__FILE__) + '/test_helper.rb'
12
-
13
- class ActsAsYaffleTest < Test::Unit::TestCase
14
- end
15
- ------------------------------------------------------
16
-
17
- *vendor/plugins/yaffle/lib/yaffle.rb*
18
-
19
- [source, ruby]
20
- ------------------------------------------------------
21
- require 'yaffle/acts_as_yaffle'
22
- ------------------------------------------------------
23
-
24
- *vendor/plugins/yaffle/lib/yaffle/acts_as_yaffle.rb*
25
-
26
- [source, ruby]
27
- ------------------------------------------------------
28
- module Yaffle
29
- # your code will go here
30
- end
31
- ------------------------------------------------------
32
-
33
- Note that after requiring 'acts_as_yaffle' you also have to include it into ActiveRecord::Base so that your plugin methods will be available to the rails models.
34
-
35
- One of the most common plugin patterns for 'acts_as_yaffle' plugins is to structure your file like so:
36
-
37
- *vendor/plugins/yaffle/lib/yaffle/acts_as_yaffle.rb*
38
-
39
- [source, ruby]
40
- ------------------------------------------------------
41
- module Yaffle
42
- def self.included(base)
43
- base.send :extend, ClassMethods
44
- end
45
-
46
- module ClassMethods
47
- # any method placed here will apply to classes, like Hickwall
48
- def acts_as_something
49
- send :include, InstanceMethods
50
- end
51
- end
52
-
53
- module InstanceMethods
54
- # any method placed here will apply to instaces, like @hickwall
55
- end
56
- end
57
- ------------------------------------------------------
58
-
59
- With structure you can easily separate the methods that will be used for the class (like `Hickwall.some_method`) and the instance (like `@hickwell.some_method`).
60
-
61
- === Add a class method ===
62
-
63
- This plugin will expect that you've added a method to your model named 'last_squawk'. However, the plugin users might have already defined a method on their model named 'last_squawk' that they use for something else. This plugin will allow the name to be changed by adding a class method called 'yaffle_text_field'.
64
-
65
- To start out, write a failing test that shows the behavior you'd like:
66
-
67
- *vendor/plugins/yaffle/test/acts_as_yaffle_test.rb*
68
-
69
- [source, ruby]
70
- ------------------------------------------------------
71
- require File.dirname(__FILE__) + '/test_helper.rb'
72
-
73
- class Hickwall < ActiveRecord::Base
74
- acts_as_yaffle
75
- end
76
-
77
- class Wickwall < ActiveRecord::Base
78
- acts_as_yaffle :yaffle_text_field => :last_tweet
79
- end
80
-
81
- class ActsAsYaffleTest < Test::Unit::TestCase
82
- load_schema
83
-
84
- def test_a_hickwalls_yaffle_text_field_should_be_last_squawk
85
- assert_equal "last_squawk", Hickwall.yaffle_text_field
86
- end
87
-
88
- def test_a_wickwalls_yaffle_text_field_should_be_last_tweet
89
- assert_equal "last_tweet", Wickwall.yaffle_text_field
90
- end
91
- end
92
- ------------------------------------------------------
93
-
94
- To make these tests pass, you could modify your `acts_as_yaffle` file like so:
95
-
96
- *vendor/plugins/yaffle/lib/yaffle/acts_as_yaffle.rb*
97
-
98
- [source, ruby]
99
- ------------------------------------------------------
100
- module Yaffle
101
- def self.included(base)
102
- base.send :extend, ClassMethods
103
- end
104
-
105
- module ClassMethods
106
- def acts_as_yaffle(options = {})
107
- cattr_accessor :yaffle_text_field
108
- self.yaffle_text_field = (options[:yaffle_text_field] || :last_squawk).to_s
109
- end
110
- end
111
- end
112
-
113
- ActiveRecord::Base.send :include, Yaffle
114
- ------------------------------------------------------
115
-
116
- === Add an instance method ===
117
-
118
- This plugin will add a method named 'squawk' to any Active Record objects that call 'acts_as_yaffle'. The 'squawk' method will simply set the value of one of the fields in the database.
119
-
120
- To start out, write a failing test that shows the behavior you'd like:
121
-
122
- *vendor/plugins/yaffle/test/acts_as_yaffle_test.rb*
123
-
124
- [source, ruby]
125
- ------------------------------------------------------
126
- require File.dirname(__FILE__) + '/test_helper.rb'
127
-
128
- class Hickwall < ActiveRecord::Base
129
- acts_as_yaffle
130
- end
131
-
132
- class Wickwall < ActiveRecord::Base
133
- acts_as_yaffle :yaffle_text_field => :last_tweet
134
- end
135
-
136
- class ActsAsYaffleTest < Test::Unit::TestCase
137
- load_schema
138
-
139
- def test_a_hickwalls_yaffle_text_field_should_be_last_squawk
140
- assert_equal "last_squawk", Hickwall.yaffle_text_field
141
- end
142
-
143
- def test_a_wickwalls_yaffle_text_field_should_be_last_tweet
144
- assert_equal "last_tweet", Wickwall.yaffle_text_field
145
- end
146
-
147
- def test_hickwalls_squawk_should_populate_last_squawk
148
- hickwall = Hickwall.new
149
- hickwall.squawk("Hello World")
150
- assert_equal "squawk! Hello World", hickwall.last_squawk
151
- end
152
-
153
- def test_wickwalls_squawk_should_populate_last_tweeted_at
154
- wickwall = Wickwall.new
155
- wickwall.squawk("Hello World")
156
- assert_equal "squawk! Hello World", wickwall.last_tweet
157
- end
158
- end
159
- ------------------------------------------------------
160
-
161
- Run this test to make sure the last two tests fail, then update 'acts_as_yaffle.rb' to look like this:
162
-
163
- *vendor/plugins/yaffle/lib/yaffle/acts_as_yaffle.rb*
164
-
165
- [source, ruby]
166
- ------------------------------------------------------
167
- module Yaffle
168
- def self.included(base)
169
- base.send :extend, ClassMethods
170
- end
171
-
172
- module ClassMethods
173
- def acts_as_yaffle(options = {})
174
- cattr_accessor :yaffle_text_field
175
- self.yaffle_text_field = (options[:yaffle_text_field] || :last_squawk).to_s
176
- send :include, InstanceMethods
177
- end
178
- end
179
-
180
- module InstanceMethods
181
- def squawk(string)
182
- write_attribute(self.class.yaffle_text_field, string.to_squawk)
183
- end
184
- end
185
- end
186
-
187
- ActiveRecord::Base.send :include, Yaffle
188
- ------------------------------------------------------
189
-
190
- .Editor's note:
191
- NOTE: The use of `write_attribute` to write to the field in model is just one example of how a plugin can interact with the model, and will not always be the right method to use. For example, you could also use `send("#{self.class.yaffle_text_field}=", string.to_squawk)`.
@@ -1,46 +0,0 @@
1
- == Appendix ==
2
-
3
- === References ===
4
-
5
- * http://nubyonrails.com/articles/the-complete-guide-to-rails-plugins-part-i
6
- * http://nubyonrails.com/articles/2006/05/09/the-complete-guide-to-rails-plugins-part-ii
7
- * http://github.com/technoweenie/attachment_fu/tree/master
8
- * http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html
9
-
10
- === Final plugin directory structure ===
11
-
12
- The final plugin should have a directory structure that looks something like this:
13
-
14
- ------------------------------------------------
15
- |-- MIT-LICENSE
16
- |-- README
17
- |-- Rakefile
18
- |-- generators
19
- | `-- yaffle
20
- | |-- USAGE
21
- | |-- templates
22
- | | `-- definition.txt
23
- | `-- yaffle_generator.rb
24
- |-- init.rb
25
- |-- install.rb
26
- |-- lib
27
- | |-- acts_as_yaffle.rb
28
- | |-- commands.rb
29
- | |-- core_ext.rb
30
- | |-- routing.rb
31
- | `-- view_helpers.rb
32
- |-- tasks
33
- | `-- yaffle_tasks.rake
34
- |-- test
35
- | |-- acts_as_yaffle_test.rb
36
- | |-- core_ext_test.rb
37
- | |-- database.yml
38
- | |-- debug.log
39
- | |-- routing_test.rb
40
- | |-- schema.rb
41
- | |-- test_helper.rb
42
- | `-- view_helpers_test.rb
43
- |-- uninstall.rb
44
- `-- yaffle_plugin.sqlite3.db
45
- ------------------------------------------------
46
-