在我的用户 Controller /模型中,我正在创建一个用户。
当我重定向到用户

format.html { redirect_to(@user, :notice => 'You have successfully registered!') }

我的页面上显示了一个很好的通知

当我尝试重定向到没有对象的不同 Controller 时
 format.html { redirect_to(:controller => 'profiles', :action => 'index', :notice => 'You have successfully registered!') }

我在 url 上收到通知,但没有显示在我的页面上。
profile?notice=You+have+successfully+registered%21

有什么方法可以将通知放入某个对象并将其显示在我的页面上?

最佳答案

format.html {
 flash[:notice] = 'You have successfully registered!'
 redirect_to(:controller => 'profiles', :action => 'index')
}

或者试试这个
format.html { redirect_to(:controller => 'profiles', :action => 'index'), :notice => 'You have successfully registered!' }

关于ruby-on-rails - Rails Flash 通知不在 url 上,而是在对象中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7057024/

10-10 05:12