Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Flash notice not on url but in object

In my user controller/model I'm creating a user. When I redirect to user

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

I get a nice notice displayed on my page

When I try to redirect to a different controller without an object

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

I get the notice on the url and not displayed on my page.

profile?notice=You+have+successfully+registered%21

is there any way to put the notice into some object and display it on my page?

like image 961
Sharethefun Avatar asked Dec 16 '22 10:12

Sharethefun


1 Answers

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

or try this

format.html { redirect_to(:controller => 'profiles', :action => 'index'), :notice => 'You have successfully registered!' }
like image 124
fl00r Avatar answered Jan 30 '23 10:01

fl00r