I am trying to display a notice after redirecting to a page but it doesnt appear.
Here is the redirect -
redirect_to :action => :index, :notice => "My redirect"
You can see the message in the url but there doesnt seem to be any code inside active admin to display it.
Any ideas how to render it inside active admin ?
They are stored in your session store. The default since rails 2.0 is the cookie store, but check in config/initializers/session_store.
Run the generator to install Active Admin. This will create an AdminUser model, an initializer file for configuring Active Admin and an app/admin directory that will hold the administration files. It uses Devise for authentication.
Active Admin is a framework for creating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.
There seems to be some issue that I haven't tracked down yet, but if you are looking for a work-around until then, this is what I did:
member_action :test do
flash[:notice] = "This is a test notice!"
redirect_to :action => :index
end
The problem that I am seeing is that when you put :notice
in the redirect_to
method, the notice message is url encoded and added to the URL
member_action :test do
redirect_to :action => :index, :notice => "This is a test notice!"
end
results in
/admin/model?notice=This+is+a+test+notice!
which is less than ideal. I noticed a change to the active_admin documentation that includes putting {}
around the first parameter to redirect_to
to fix this problem, however, for me, this results in an error.
member_action :test do
redirect_to {:action => :index}, :notice => "This is a test notice!"
end
which results in
syntax error, unexpected tASSOC, expecting '}'
redirect_to {:action => :index}, :notice => "This...
I posted a comment on that particular pull request @ active_admin on github and hopefully someone might have another suggestion, since I am stumped.
In any event, maybe one of these solutions will work for you. Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With