Rails 登陆页面

发布于 2024-09-06 11:22:27 字数 350 浏览 2 评论 0原文

我决定在我的网站 goldhat.org 上放置一个登陆页面。我希望用户在登录后能够直接进入此页面,在未登录时被定向到登录页面。登录页面当前位于 这里。如果点击顶部的“浏览网站”链接,它将转到当前的主页。

基本上我想要登陆页面和当前主页来共享“www.goldhat.org”网址。我可以看出这在登录后是多么容易做到吗?有条件的,但是对于未登录并浏览该网站的人呢?我真的只想让登陆页面显示一次。

有什么想法吗?

I've decided to put a landing page on my website goldhat.org. I want users to be able to go directly to this page if they are logged in and be directed to a landing page if they aren't logged in. The landing page is currently sitting here. If one clicks on the "browse website" link at the top, it will go to what is currently the home page.

Basically I want the landing page and what is currently the home page to share the "www.goldhat.org" web address. I can see how this is easy enough to do with a logged in? conditional, but what about someone who isn't logged in and browses the site. I only really want the landing page to be displayed once.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄想挽回 2024-09-13 11:22:27

使用会话变量来跟踪未登录的访问者是否查看了登录页面。大致如下:

def index
  if !logged_in? && !session[:visited_welcome_page]
    redirect_to welcome_path
  else
    # Render the main view of goldhat.org
  end
end

def welcome
  session[:visited_welcome_page] = true
  # Render welcome view
end

Use a session variable to keep track of whether a visitor that is not logged in has viewed the landing page or not. Something along the lines of:

def index
  if !logged_in? && !session[:visited_welcome_page]
    redirect_to welcome_path
  else
    # Render the main view of goldhat.org
  end
end

def welcome
  session[:visited_welcome_page] = true
  # Render welcome view
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文