views:

103

answers:

1

I am talking about rails resource_controller gem plugin here:

Basically when I am doing json format, I would like to completely suppress the flash notice if possible, trying to call flash "" will fail, while calling flash[:notice]="" doesn't look really nice either. Is there some better approach?

A: 

I don't use that particular gem, but I think this should work anyway.

In your ApplicationController:

def set_xhr_flash
  flash.discard if request.xhr?
end

Then just make sure you call it as an after_filter

after_filter :set_xhr_flash
Andy Gaskell