The respond_with
combination (which is built into Rails) combined with the responders
gem makes InheritedResources obsolete.
Please see this blog post for a great explanation and demonstration of how to create a RESTful controller using respond_with
. Most controller actions come down to single lines of code; with InheritedResources, it was possible to have a controller without code (because it was hidden in a gem), but Jose Valim (creator of InheritedResources) thought this was too confusing according to his quote:
"I found that responder abstraction and Rails custom generators provide the perfect balance between hiding and showing too much logic."
responders
comes into play if you want to automate any other parts of the controllerβs action, such as installing flash messages.
UPDATE: for a commenter who asked about destroy
action
def destroy record = Record.find(params[:id]) flash[:notice] = "The record has been destroyed successfully" if record.destroy respond_with record end
source share