我正在构建我的第一个 Rails 应用程序,出于某种奇怪的原因,用户会话似乎被丢弃了,我不知道如何修复它。我的意思是,我的索引模板的设置<% if user_signed_in? %>
是真的,他们只会看到包含所有数据的应用程序,否则他们会看到一个注册页面。一切似乎都正常,但是当您在登录后刷新页面时,退出 ( destroy_user_session_path
) 按钮之类的东西就会消失。
下面是我的代码。忽略所有 Angular 的东西——我放弃它是因为我决定过早地使用它。
<% if user_signed_in? %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<div class="site_container" ng-controller="SubmissionsCtrl">
<div class= "row-fluid" id="indexrow">
<div class="span7">
<form id="postSubmit" action="/submissions" method="post">
<%= hidden_field_tag :user_id, current_user.id %>
<label for="titleinput">Title</label>
<input type="text" id="titleinput" name="title" placeholder="Title"></input>
<label for="contentinput">Content</label>
<textarea id="contentinput" rows="6" name="content" placeholder="What's on your mind?"></textarea>
<button type="submit" class="btn btn-primary" style="margin-top:10px">Save</button>
</form>
</div>
<div class="span5">
<div id="submission-list-container">
<ul id="indexSubmissions">
<% current_user.submissions.each do |i| %>
<%= i.title %>
<%= i.content %>
<% end %>
</li>
</ul>
</div>
</div>
</div>
</div>
<% else%>
<div id="intro_page_center">
<h2 id="big_intro">Explore your mind.</h2>
<div id="registration_login">
<a href="users/sign_in" class="sign_in_up">Log in</a>
<a href="users/sign_up" class="sign_in_up">Sign up</a>
</div>
<div id="about_container">
<ul id="about_braindb">
<li>
<h3>Save <small>Save stories, videos, recipes, and anything else that defines you.</small></h3>
</li>
<li>
<h3>Learn <small>Discover patterns, connections, and meaningful context in everything you save to BrainDB.</small></h3>
</li>
<li>
<h3>Grow <small>Utilize your newfound abilities to read your subconcious through idea generation, collaboration, and more.</small></h3>
</li>
</ul>
</div>
</div>
<% end%>
知道它可能是什么吗?我在某处看到它可能与 Rails 3 安全性和我的 POST 表单提交有关,但我丢失了页面并且找不到更多信息。