简体   繁体   English

首次使用 Ruby on Rails + Devise 登录后显示模式(仅 1 次)

[英]Display modal (only 1 time) after first login with Ruby on Rails + Devise

I'm trying to show an introduction modal to new user after the first sign in.我正在尝试在首次登录后向新用户显示介绍模式。

  <% if user_signed_in? && current_user.sign_in_count == 1 %>
      <%= render 'introduction_slides' %>
  <% end %>

The sign_in_count works great. sign_in_count 很好用。 but the problem is that user needs to signout and in to stop seeing that modal.但问题是用户需要注销并登录才能停止看到该模式。 Is there any better way to make this happen?有没有更好的方法来实现这一目标? Maybe using Cookie?也许使用 Cookie?

I figured out with Session 👍我想通了Session 👍

<% if user_signed_in? && current_user.sign_in_count == 1 %>
  <% unless session[:introduction_slides] %>
    <%= render 'introduction_slides' %>
    <% session[:introduction_slides] = true %>
  <% end %>
<% end %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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