Activeadmin: Error flash message not shown

Created on 22 Oct 2012  ·  3Comments  ·  Source: activeadmin/activeadmin

In an ActiveAdmin controller, the :error flash message is not visible.

Doing this, you get the flash message shown:

redirect_to admin_phone_path(@phone), notice: 'A nice message - this one is visible.' 

but when trying to show an error, nothing is shown.

redirect_to admin_phone_path(@phone), error: 'A less nice error message - this one is NOT visible.'

Same behavior is seen on default CRUD actions of the controllers created by ActiveAdmin.
This means you won't know your operation didn't work when you tried to update an object and the validation failed and prevented the save.

Most helpful comment

error is not valid option for redirect_to. You may want to use alert
or if you really need error use it like that:

redirect_to admin_phone_path(@phone), flash: {error: 'A less nice error message - this one is NOT visible.'}

All 3 comments

error is not valid option for redirect_to. You may want to use alert
or if you really need error use it like that:

redirect_to admin_phone_path(@phone), flash: {error: 'A less nice error message - this one is NOT visible.'}

@arthwood provided the correct answer, :error is not a supported flash message by default, but you can pass arbitrary keys along with the flash hash.

If i want to display the multiple errors, how can i do

Was this page helpful?
0 / 5 - 0 ratings