public
Description: resources_controller rails plugin: rc makes RESTful controllers fun
Homepage: http://plugins.ardes.com/doc/resources_controller
Clone URL: git://github.com/ianwhite/resources_controller.git
Click here to lend your support to: resources_controller and make a donation at www.pledgie.com !
resources_controller / CHANGELOG
633fe459 » ianwhite 2008-09-08 Added note about spec:gener... 1 * rspec compat: Added new rake task to test that an RC controller passes the default rspec_scaffold
2 controller specs.
3
10eaea5c » ianwhite 2008-04-27 Fixed failing regression sp... 4 * Added BC for 2-0-stable branch re: find_filter, and regression specs
5
6 * find_filter no longer exists in edge - updated accordingly [Jason Lee http://github.com/jlsync]
7
46db2a16 » ian 2008-01-26 resources_controller: Added... 8 * Added ability to pass options to named route in form_for_resource
9
10 form_for_resource :url_options => {:gday => 'mate'}
11
12 # => action="/products/1?gday=mate" (for update)
13 # => action="/products?gday=mate" (for create)
14
1dca7585 » ian 2007-11-19 resources_controller: * cha... 15 * changed :erp to :resource_path, and added :resource_method.
16
17 This means you can connect a named route up with a REST action and also change the method
18
19 map.activate_account '/activate/:code', :controller => 'activations', :action => 'create', :resource_path => '/activations', :resource_method => :post
20
21 :erp retained for BC
22
23 * save_resource and resource_saved? added. These simply save the resource and cache
24 the result of that save. This means you can use the result of the resource save in your
25 response_for blocks (if you're using response_for)
26
27 response_for :create do |format|
28 if resource_saved?
29 format.html {}
30 else
31 format.html {}
32 end
33 end
34
35 def create
36 self.resource = new_resource
37 save_resource
38 end
39
cfa3d5e9 » ian 2007-11-18 resources_controller: added... 40 * added Ardes::ResourcesController.actions and
41 Ardes::ResourcesController.singleton_actions accessors so you can set the
42 default actions module across your app
43
dd20dcd5 » ian 2007-11-18 resources_controller: Added... 44 * Added resource_saved? method to controller. This is useful for sharing the
45 result of a save outside action methods (for example in response_for blocks)
46
8447d4c8 » ian 2007-11-15 resources_controller: added... 47 * added error_messages_for_resource to Helper
48
49 * fixed form_for_resource when resource is new and controller is for singleton
50 resource
51
6f90688e » ian 2007-11-14 resources_controller: added... 52 * added :erp patch, doc and specs [thanks Chris Hapgood for the initial patch]
53
54 Use the :erp param when you are routing a non RESTful route to your rc controller
55 This allows rc to load the resources using the route.
56
57 e.g. map.home '', :controller => 'forums', :action => 'index', :erp => '/forums'
58
c3af1679 » ian 2007-11-06 Removed deprecated options ... 59 * Removed deprecated options (in r492 - I forgot to say so)
60
fc138623 » ian 2007-11-06 resources_controller: cover... 61 * Coverage back to 100%
62
1b8be92d » ian 2007-11-06 resources_controller: you c... 63 * you can alias an enclosing resource with :as
64
65 This can be useful when you have a tree like domain:
66
67 map.resources :categories do |category|
68 category.resources :categories
69 end
70
71 class CategoriesController < ApplicationController
72 resources_controller_for :categories
73 map_resource :category, :as => :parent
74 end
75
983e0df4 » ian 2007-11-06 resources_controller: you c... 76 * you can now specify which actions are loaded from the actions module
77
78 resources_controller_for :forums, :only => [:index, :show]
79 resources_controller_for :forums, :actions => MyActions, :except => :destroy
80
81 The method used to achieve this is Ardes::ResourcesController::include_actions
82 which can be used in any ActionController when resources_controller is in your
83 plugins directory
84
44316d0a » ian 2007-10-24 resources_controller: - :po... 85 * - :polymorphic => true is back:
86 resources_controller_for :tags
87 nested_in :taggable, :polymorphic => true
88
89 This will load the enclosing resource (which can be a mapped resource) as
90 @taggable as well as its default name
91
92 The following syntax is equivalent to the above two lines:
93 resources_controller_for :tags, :in => '?taggable'
94
95 And you can specify a single wildcard '?' as well as expanding wildcards '*':
96 resources_controller_for :images, :in => '?', :load_enclosing => false
97 # this will work for routes like /users/1/images, /forums/2/images, /featured/images
98
99 - test coverage is up
100
101 - moved some of the 'friend' functionality out of Specification, as it smelt bad
102
e8fc1910 » ian 2007-10-12 resources_controller: added... 103 * added specs for when you want to find_by_(something other than id) (users,
104 addresses, interests)
105
106 Fixed a bug where the resource mapping was using name instead of segment to
107 match when a map should be used (this meant mapping didn't work for non
108 singleton resources)
109
110 Thanks to Inviz <invi...@gmail.com> and Matt Mower <matt.mo...@gmail.com>
111 in http://groups.google.com/group/resources_controller/browse_thread/thread/b71b2ce196a09d15
112 for the bug reports
113
6bf23347 » ian 2007-10-10 resources_controller: Updat... 114 * Updated actions to be more in line with recent rails scaffold [Jason Lee <jlsync@gmail.com>]
115
604a147c » ian 2007-10-04 resources_controller now us... 116 * resources_controller now uses before_filter (instead of prepend_before_filter)
117 for load_enclosing_resources. So the resources will be loaded at the point
118 where resources_controller_for is specified. However, it only adds the
119 filter if it's not already there - so you can play around with the order if
120 you need to:
121
122 prepend_before_filter :load_enclosing_resources
123 resources_controller_for :foos
124
125 (common case for the above is where superclass defines filters that need
126 access to enclosing resources)
127
1c137a5a » ian 2007-10-02 reosurces_controller: resou... 128 * resources_controller_for can now be specified more than once in a controller
129 heirachy. The latter definition will overwrite the previous one, and will
130 also 'reset' the nestings.
131
1dada759 » ian 2007-09-18 resources_controller: First... 132 * First stab at namespace support:
133 map.namespace :admin do |admin|
134 admin.resources :forums
135 end
136
137 module Admin
138 module Forums < ApplicationController
139 resources_controller_for :forums
140 end
141 end
142
143 in an action:
144 resources_path # => '/admin/forums'
145 enclosing_resources # => []
146
f8a38784 » ian 2007-09-06 Minor doc improvements 147 * Minor doc improvements
148 Speced better js response on edit and new actions [Jason Lee <jlsync@gmail.com>]
149
00595022 » ian 2007-09-06 resources_controller: The R... 150 * The Routing patch has been removed from RC as it has been accepted and applied to edge (#8930).
151 This is not a dependency of RC, but it is of the specs - so grab latest edge to run them.
152
2200ba91 » ian 2007-09-05 * Major internal changes, a... 153 * Major internal changes, and some API change: see the rdoc for details.
154 The headlines:
155 - load_enclosing is now true by default
156 - BC: the old options work for now, but you'll get deprecation messages
157 - refactored a lot of code into friend classes - in particular there is now
158 ResourcesController::Specification which specifies how to find a resource from the route
159
1dc4d3f7 » ian 2007-08-23 resources_controller: 160 * Fixed some problems with internals of RC when :load_enclosing => true
161
68ddf96f » ian 2007-08-18 * resources_controller now ... 162 * resources_controller now supports singleton resources! and much better :load_enclosing support
163 Booya! =>
164 class TagsController < ApplicationController
165 resources_controller_for :tags, :load_enclosing => true
166 end
167
168 this will service all these routes (loading the resources into assigns for the view)
169
170 /tags
171 /forums/2/tags
172 /images/1/tags
173 /home/tags <= singular resource
174 /users/1/image/tags <= nested singular resource
175
176 Also
177
178 class BlogController < ApplicationController
179 resources_controller_for :blog, :singleton => true, :load_enclosing => true
180 end
181
182 class PostController < ApplicationController
183 resources_controller_for :post, :load_enclosing => true
184 end
185
186 for /campaigns/1/blog
187 /users/2/blog
188 /campaigns/1/blog/posts
189 /users/2/blog/posts
190
191 etc...
192
193 TODO: rewrite docs - for now check out the spec suite.
194 TODO: refactor code - I did it BDD stylee, so there's lots of specs but also a lot of code that 'is the simplest thing that makes the specs pass'
195
48c58cdc » ian 2007-08-18 resources_controller: 196 * resources_request has changed format - it now returns an array like this
197 [ {:name => "forums", :name_prefix => "forum_", :key => :forum_id, :id => "1"}, {:name => "posts"}]
198 Singular resources are detected properly (see spec/specs/resources_controller_spec for some tests).
199 This paves the way for singular_resource support, and better 'many routes/one controller' support
200
201 Decided that Patching Routing was a bad idea, so route is re-recognized using the request path. This
202 only happens for controllers with :load_enclosing => true
203
18e39391 » ian 2007-08-17 resources_controller: 204 * You can now call methods such as enclosing_resource_path, enclosing_resources_path, etc
205 in your controller and view and the correct url helper will be called. These url_helpers are defined
206 as they are needed, so it's pretty fast.
207
208 * Removing routing decoration for now
209
f4f78c80 » ian 2007-08-17 resources_controller 210 * Enclosing resources are now all loaded by one method :load_enclosing which is a prepend_before_filter.
211 This means that you can access the enclosing resources in all before_filters, even when a subclass adds
212 more nestings.
213
214 Example:
215
216 class PostsController < ApplicationController
217 resources_controller_for :posts
218 end
219
220 class UserPostsController < PostsController
221 nested_in :user
222
223 before_filter {|c| raise 'boom' if @user.name == 'Santa'}
224 end
225
f3d7fc4e » ian 2007-08-17 resources_controller: 226 * Removed ResourceService proxy class. This was mainly used for BC with rails <= 1.2.2. If you're
227 using this, then freeze to r377 of resources_controller. The resource_service is now either an
228 ActiveRecord or association proxy.
229
230 * Added route decoration to access the recognized route in the controller (for future parsing of
231 singular resources, and better polymorphic support)
232
bee172f7 » ian 2007-08-17 resources_controller: Remov... 233 * Removed Ardes::ResourcesController::Spec::ViewHelper as it's best to not have a dependency
234 like this in your specs. Just stub out the resource methods that are needed by that view,
235 or use the default assigns.
236
0c5fcae0 » ian 2007-07-30 Named path support is much ... 237 * Named path support is much improved. All named routes for the current resource can be
238 called by substituting 'resource'. E.g. the following methods in your controller or
239 view will work: :formatted_resource_path, :preview_resource_path (if :preview is in :member),
240 :resource_tags_path, etc, etc.
241 This helps with decoupling the model name from the controller and view.
242
8cf4badb » ian 2007-07-23 resources_controller: Added... 243 * Added flash tests [frederikfix at eml dot cc]
244
1535036c » ian 2007-07-23 resources_controller: Added... 245 * Added rjs actions [frederikfix at eml dot cc]
246
1f3e3f47 » ian 2007-07-09 Added Ardes::ResourcesContr... 247 * Added Ardes::ResourcesController::Spec::ViewHelper for easy view testing
248
100ae489 » ian 2007-07-09 Added Helper#form_for_resou... 249 * Added Helper#form_for_resource for easy form generation, see rdoc for details
250
b7750a58 » ian 2007-07-09 * Enclosed named paths use ... 251 * Enclosed named paths use the new edge rails conventions for named routes.
252
253 So to get the path to edit a child tag resource (where resource is 'forum:1')
254 edit_resource_tag_path(@tag) # => '/forums/1/tags/2/edit'
255
256 * Handles options passed to named routes
257
258 resource_path(:sort_by => 'article') # => '/forums/2?sort_by=article'
259
0181a4ad » ian 2007-06-07 Now handles enclosing named... 260 * Now handles enclosing named paths. You can reference named routes that are
261 'below' (or enclosed by) the current resource by appending resource_ to that
262 named route. [thanks Chris Hapgood for the initial idea]
263
4e33aa81 » ian 2007-06-07 resources_controller: (find... 264 * (find|new)_resource(s) methods are now defined by resources_controller_for only
265 if they do not already exist
266
84470fa6 » ian 2007-05-30 resources_controller: Bette... 267 * Better regexp for resources_request [Chris Hapgood]
268
f042826b » ian 2007-05-10 resources_controller: Added... 269 * Added more specs to get coverage to 100%
270
6dccf6a7 » ian 2007-05-10 Upgraded specs for latest e... 271 * Upgraded to rpsec 0.9, improved Rakefile and specs so that spec:plugins will work
272
4d8e78dc » ian 2007-02-28 Removed ApplicationControll... 273 * Removed ApplicationController from spec/app.rb to avoid conflicts with en-
274 closing rails application
275
20d4f25a » ian 2007-02-22 Added method_missing proxy ... 276 * Added method_missing proxy to ResourceService, to enable the resource_service
277 to be used for things other than find or new (for example Pagination) [Dan Kubb]
278
063f4813 » ian 2007-02-22 git-svn-id: https://svn.ard... 279 * Fixed small error in flash message of destroy action [Dan Kubb]
280
7a47cc18 » ian 2007-02-22 Removing experimental cruft 281 * Removing experimental cruft
282
6bf23347 » ian 2007-10-10 resources_controller: Updat... 283 * CHANGELOG started