上的Flash消息我試圖在重定向到頁面後顯示通知,但它不出現。活動管理員 - 未出現在第
這裏是重定向 -
redirect_to :action => :index, :notice => "My redirect"
你可以看到消息中的網址但似乎沒有被激活管理員顯示它內部的任何代碼。
任何想法如何將其呈現在活動管理員內?
上的Flash消息我試圖在重定向到頁面後顯示通知,但它不出現。活動管理員 - 未出現在第
這裏是重定向 -
redirect_to :action => :index, :notice => "My redirect"
你可以看到消息中的網址但似乎沒有被激活管理員顯示它內部的任何代碼。
任何想法如何將其呈現在活動管理員內?
似乎有一些問題,我沒有跟蹤下來了,但如果你正在尋找一個變通此之前,這是什麼我所做的:
member_action :test do
flash[:notice] = "This is a test notice!"
redirect_to :action => :index
end
,我看到的問題是,當你把:notice
在redirect_to
方法,通知消息的URL編碼並添加到URL
member_action :test do
redirect_to :action => :index, :notice => "This is a test notice!"
end
/admin/model?notice=This+is+a+test+notice!
這是不理想的。我注意到對active_admin文檔的更改,其中包括將{}
圍繞第一個參數設置爲redirect_to
來解決此問題,但是,對於我來說,這會導致錯誤。
member_action :test do
redirect_to {:action => :index}, :notice => "This is a test notice!"
end
導致
syntax error, unexpected tASSOC, expecting '}'
redirect_to {:action => :index}, :notice => "This...
我張貼在那個特定的拉動請求@active_admin on github評論,希望有人可能有另一項建議,因爲我難倒。
無論如何,其中一種解決方案可能適合您。祝你好運。
flash [:notice] work around爲我工作。我花了一個小時搞這個,直到找到答案。 – jevy
您在使用ruby語法時遇到問題。嘗試添加括號:'redirect_to({action::index},注意:'無論')' – chrpes
在成員動作中使用'flash [:notice]'對我來說無法正常工作(不會消失),但@chrpes提供的上述解決方案的確如此。 – SexxLuthor
Active Admin不呈現Flash消息,它認爲它們呈現在t layout中呈現它們。 當您運行active_admin:安裝發電機也提到:
$ rails g active_admin:install
...
Some setup you must do manually if you haven't yet:
...
3. Ensure you have flash messages in app/views/layouts/application.html.erb. For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
你有一個: <%= flash [:notice]%> 在你看來? – Cygnusx1
活動管理員生成的意見,所以我不知道。 – Alex