Summary
The 0.60.0 release contains a significant change to all controllers within Spree as they have been refactored to remove the use of the resource_controller gem. This release may have an impact on existing extensions or site customizations that leverage some of resource_controllers features, so it’s important to read the details on it’s removal below and review any code which might be affected.
While the removal of resource_controller is not most glamous or exciting change, it’s another significant stepping stone to our 1.0 release.
We’re always looking for more help with the Spree documentation. If you’d like to offer assistance please contact us on the spree-user mailing list and we can give you commit access to the documentation project.
Database Migrations
There are no database migrations to worry about in this release (assuming you are already running Spree 0.50.x).
Always be sure to perform a complete database backup before performing any operations.
Removal of resource_controller
The resource_controller gem has been central to Spree’s controllers from one it’s earliest releases and was responsible for some of Spree’s customizability features. It’s removal has been discussed (endlessly) and worked on for quite some time. It’s original lack of Rails 3.0 support delayed Spree’s 0.30.0 release for sometime while we forked and updated the gem to support Rails 3. However it was still felt that the library was too overbearing for Spree’s needs and added unneeded complexity to it’s controllers.
Some earlier Spree releases removed its usage from the more complex front-end controllers (like OrdersController and CheckoutController) and this release extends this to all front-end controllers.
Supported Functionality
The majority of backend (Admin) controllers now base off of Admin::ResourceController class which provides a much simpler and slimmed down version of resource_controllers existing features, while attempting to maintain backwards compatibility for the majority commonly used extension points.
Admin::ResourceController provides several resource_controller style features as follows.
Standard CRUD Methods
There are basic implementations of all the standard CRUD methods:
- :index
- :show
- :create
- :read
- :update
- :destroy
In Action Callbacks
- :update.before
- :create.before
- :update.after
- etc.
URL Helpers
- new_object_url
- edit_object_url
- object_url
- collection_url
Use of these generic helpers is discouraged in favor of the default Rails helper urls.
Instance Variables
- *`object+
- +`collection*
Use of these variables is strongly discouraged. Use the actual Rails standard variable names instead.
Unsupported Functionality
Admin::ResourceController does NOT provide the following resource_controller features:
Custom Responses
- create.wants.js
- update.wants.html
These have been replaced with a new method called respond_override
See the Customization guide for more details on respond_override
Deprecated Methods
These methods are deprecated and should either be removed or replaced with a custom load_resource method (see Admin::ResourceController source for details).
- object
- collection methods
The following method for custom flash messages has been removed entirely (with no replacement approach.)
- create.flash
Admin::ResourceController’s use is encouraged in extensions and/or site customizations that require basic CRUD admin controllers. It should not be used on front-end or complex admin controllers, as you can see from the current source even certain core admin controllers do not use it (for example Admin::OrdersController).
While the use of resource_controller has been completely removed from all of Spree’s core controllers, the dependency on resource_controller gem will remain for a while to allow extension authors to update their projects.
Miscellaneous Changes
There are also a series of minor bug fixes and improvments. Please see the Github compare for more details.