2013-07-04 2 views
0

첫 번째 Rails 앱을 만들고 있는데, 이상한 이유로 사용자 세션이 버려진 것처럼 보이고 수정 방법을 모르겠습니다. 내 인덱스 템플릿이 설정되어 <% if user_signed_in? %>이 맞으면 모든 데이터가 포함 된 앱이 표시되고 가입 ​​페이지는 표시됩니다. 모두 은 작동하려면으로 보이지만 로그인 한 후 페이지를 새로 고침하면 로그 아웃 (destroy_user_session_path) 버튼과 같은 항목이 사라집니다.Rails 앱 사용자 세션이 제대로 작동하지 않습니까?

아래 코드는 제 코드입니다. 모든 각도의 것들을 무시하십시오. - 나는 그것을 조기에 사용하기로 결정했기 때문에 그것을 멀리하고 있습니다.

<% 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%> 

어떤 아이디어 일 수 있습니까? 나는 그것이 레일즈 3 보안과 POST 폼 제출과 관련 될 수있는 곳을 보았지만, 페이지를 잃어 버렸고 더 많은 정보를 찾을 수 없었다.

+0

'user_signed_in?'을 어떻게 정의했는지 보여주는 것이 좋습니다. –

+0

나는 Devise를 이용하고 있습니다. –

+0

보기에서 다음을 인쇄 할 수 있습니다 :'<% = session.inspect %>' –

답변

0

컨트롤러에 before_filter를 추가 했습니까?

before_filter :authenticate_user! 
+0

예, 제출 컨트롤러에 있습니다. –

+0

@TomMaxwell이 작업을 수행 했습니까? – dewdrops

관련 문제