1

I was running rails 3.2.1 and using rails 3 responders as well as the flash responder available in the responders gem: https://github.com/plataformatec/responders

For some of my controller actions I always want to redirect back to the previous URL but display a flash message if the object is created or not, it looks something like this:

class MyController < ActionController::Base
  responders :flash
  respond_to :html

  def create
    @my_object = MyObject.create(params[:my_object])
    respond_with @my_object do |format|
      format.html { redirect_to :back }
    end
  end
end

This works fine in rails 3.2.1 but seems to have stopped working in 3.2.2, there seems to have been some modifications about how respond_with functions when taking a block. Specifically this patch: https://github.com/rails/rails/pull/4870/files

I was wondering if there's any way to achieve this same behaviour and use the flash responder to set the flash messages (I don't want to have to do it manually).

Mario Visic
  • 2,653
  • 1
  • 22
  • 29

2 Answers2

0

You need create your own responder to do your redirect all the time and include it on your Controller.

The responder are like Rack::Middleware. You can cumulate it.

shingara
  • 46,608
  • 11
  • 99
  • 105
0

Turned out to be a bug in rails 3.2.2 https://github.com/rails/rails/pull/5299

Mario Visic
  • 2,653
  • 1
  • 22
  • 29