我的应用程序出现小问题。有条件地注册导轨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