Inherited Resources Deerecated on Rails 3 ... Defendants

I just started using InheritedResources for the application that I am creating, and when I looked at his Github page, it says that it is out of date and that I should use responders instead.

I'm new to InheritedResources and Responders, so I'm confused, how can I get from responders what I get in InheritedResources (full REST action template code) when all I see from the documentation is FlashResponders and HTTPCacheResponders?

I also looked at this:

http://blog.plataformatec.com.br/tag/inherited_resources/

does that mean that for me there is no longer "REST template code"?

+6
source share
1 answer

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 
+10
source

Source: https://habr.com/ru/post/910148/


All Articles