Rails Flash通知不在url上,而是在object中

Sha*_*fun 4 ruby-on-rails ruby-on-rails-3

在我的用户控制器/模型中,我正在创建一个用户.当我重定向到用户

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

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

当我尝试重定向到没有对象的不同控制器

 format.html { redirect_to(:controller => 'profiles', :action => 'index', :notice => 'You have successfully registered!') }
Run Code Online (Sandbox Code Playgroud)

我在网址上收到通知,但没有显示在我的网页上.

profile?notice=You+have+successfully+registered%21
Run Code Online (Sandbox Code Playgroud)

有没有办法将通知放入某个对象并将其显示在我的页面上?

fl0*_*00r 8

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

或试试这个

format.html { redirect_to(:controller => 'profiles', :action => 'index'), :notice => 'You have successfully registered!' }
Run Code Online (Sandbox Code Playgroud)