我的應用程序出現小問題。有條件地註冊導軌4
而不是讓我的訪問者登錄的選項,它是重定向訪問我的應用程序的每個人立即登錄或他們無法導航任何其他選項卡。
爲了進一步澄清我的application.html.erb文件我有以下代碼:
<% if user_signed_in? %>
Logged in as <strong><%= current_user.email %></strong>
<br>
<br>
<%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %> |
<%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link' %>
<% else %>
<%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %> |
<%= link_to "Login", new_user_session_path, :class => 'navbar-link' %> </p>
<% end %>
如果有人能幫助我指導我需要有在牌子,上面路線作爲一個選項,而不是作爲我的應用程序的所有訪問者的默認值,將不勝感激。
在我application_controller.rb文件中的代碼如下:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :authenticate_user!
end
您可以發佈相關的應用程序控制器代碼? – Jeremiah 2014-10-17 19:55:51
Jeremiah謝謝你指出,我也要添加application_controller.rb文件的代碼 – 2014-10-17 19:57:24