Best place to set the flash[:notice]?

I’m using some standard Rails Resource controllers and on a new
resource creation you’ll see something like

respond_to do |format|
flash[:notice] = ‘Company was successfully created.’
format.html { redirect_to(@company) }
format.xml { render :xml => @company, :status
=> :created, :location => @company }
format.html { render :action => “new” }
format.xml { render :xml => @company.errors, :status
=> :unprocessable_entity }

Now I’m starting to add some AJAX stuff in the dashboard of the
application and want to add a format.js to that list. This has me

Shouldn’t the flash[:notice] be inside the html block. Why is this the
default? I’m pretty sure you don’t want to set the flash when we are
dealing with XML requests. Similarly most xhr requests will deal with
notification in their own way (Yellow fade effect, and so on.)

I’m just curious as to why this is the default and see how other
people edit/use this in similar cases.

~ Mike

Michael Zornek
Clickable Bliss