简体   繁体   中英

devise dynamic flash messages

I am using devise for authentication purpose and all functionalities are working fine.

When a user signs out, The flash message which displaying is "Signed out successfully." .This can be customized in devise.en.yml.

But I need this to be dynamic (like) " user.email signed out successfully". How to make devise flash messages to be dynamic?

I managed to display this thing.

To do this we want to create a 'devise' folder in controllers and create a new controller 'sessions', and do the rest of things.

I have given my code:

def create  
  resource = warden.authenticate!(:scope => resource_name, :recall => "new")  
  session["resource_email"] = resource.email  
  flash[:notice] = "#{resource.email} signed in  successfully.."  
  sign_in_and_redirect(resource_name, resource)  
end

def destroy  
   flash[:notice] = "#{session["resource_email"]} signed out successfully.."  
   sign_out_and_redirect(resource_name)  
end 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM