我当前正在构建导航,但是遇到current_page?
问题,我希望显示登录和注册按钮,但只希望导航中的链接仅显示在欢迎/根页面上,我已经将当前页面指向了欢迎控制器和show方法。
<section class="block text-left lg:flex w-full lg:items-center lg:w-auto lg:text-right mobile-nav hidden">
<% if user_signed_in? %>
<%= link_to "Dashboard", dashboard_path, class: "inline-block text-sm px-4 py-2 leading-none text-white border border-blue-dark bg-blue-dark hover:bg-blue-darker hover:border-blue-darker no-underline mt-4 mr-4 lg:mt-0 shadow" %>
<% else %>
<% if current_page?(url_for(controller: 'welcome', action: 'show')) %>
<a href="#about" class="block mt-4 lg:inline-block lg:mt-0 font-bold text-white mr-4 no-underline sm:hover:border-b-2 sm:hover:border-white pt-2 pb-2">About Us</a>
<a href="#courses" class="block mt-4 lg:inline-block lg:mt-0 font-bold text-white mr-4 no-underline sm:hover:border-b-2 sm:hover:border-white pt-2 pb-2">Our Courses</a>
<a href="#free-training" class="block mt-4 lg:inline-block lg:mt-0 font-bold text-white mr-4 no-underline sm:hover:border-b-2 sm:hover:border-white pt-2 pb-2">Free Training</a>
<a href="#testimonials" class="block mt-4 lg:inline-block lg:mt-0 font-bold text-white mr-4 no-underline sm:hover:border-b-2 sm:hover:border-white pt-2 pb-2">Testimonials</a>
<% end %>
<%= link_to "Register", new_user_registration_path, class: "inline-block text-sm px-4 py-2 leading-none text-white border border-blue-dark bg-blue-dark hover:bg-blue-darker hover:border-blue-darker no-underline mt-4 mr-4 lg:mt-0 shadow" %>
<%= link_to "Login", new_user_session_path, class: "inline-block text-sm px-4 py-2 leading-none text-white border border-orange bg-orange hover:bg-orange-dark hover:border-orange-dark no-underline mt-4 lg:mt-0 shadow" %>
<% end %>
</section>
但是,当我进入登录页面时,我得到了这个。注册页面加载正常。