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|   if @company.save     flash[:notice] = 'Company was successfully created.'     format.html { redirect_to(@company) }     format.xml { render :xml => @company, :status => :created, :location => @company }   else     format.html { render :action => "new" }     format.xml { render :xml => @company.errors, :status => :unprocessable_entity }   end end

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 thinking...

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