ruby-on-rails – Rails Flash通知不在url上,而是在对象中
发布时间:2020-12-17 03:59:18 所属栏目:百科 来源:网络整理
导读:在我的用户控制器/模型中,我正在创建一个用户. 当我重定向到用户 format.html { redirect_to(@user,:notice = 'You have successfully registered!') } 我的页面上显示了一个很好的通知 当我尝试重定向到没有对象的不同控制器 format.html { redirect_to(:co
在我的用户控制器/模型中,我正在创建一个用户.
当我重定向到用户 format.html { redirect_to(@user,:notice => 'You have successfully registered!') } 我的页面上显示了一个很好的通知 当我尝试重定向到没有对象的不同控制器 format.html { redirect_to(:controller => 'profiles',:action => 'index',:notice => 'You have successfully registered!') } 我在网址上收到通知,但没有显示在我的网页上. 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!' } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |