배경레일 출력 내 레일 응용 프로그램에서 이야기의 모델이
올바르지 않습니다. 모델 부분 중 하나는 "published"에 대한 부울입니다.
작성 및 편집 양식에는 스토리가 게시되면 "켜기"가 게시되고 게시되지 않은 경우 "해제"로 표시되는 토글 버튼이 있습니다. 이 토글은 현재 올바르게 작동하며 스토리가 게시되거나 게시되지 않도록 전환 할 수 있습니다.; 이 토글은 그에 따라 데이터베이스를 업데이트합니다.
내가 if 문을하려고했다 쇼 페이지에서 문제
하지만이 제대로 해결되지 않은, 그래서 난 그냥 게시 된 변수에서 인쇄를했고, 항상 출력합니다 "거짓 "데이터베이스를 검사 할 때에도"true "로 설정됩니다.
강령
<% @title="Stories" %>
<p><strong><%= @story.heading %></strong></p>
<p><%= @story.body %></p>
<p>
<%= #!!!!!!!!!!!!!!!!Not working currently!!!!!!!!!!!!!
# if @story.published
# @publish_Notice = "This story has been made public."
# else
# @publish_Notice = "This story is private."
# end
# @publish_Notice
@story.published # Always prints out 'false' even when database shows 'true'
%>
</p>
<p>~ <%= @story.authorName %></p>
<p>Submitted: <%= @story.created_at.strftime("%B, %d %Y") %><br/>
<%=
@location = " "
if @story.locationCity == "" || @story.locationCity == " " || @story.locationCity.nil?
@location = " "
else
@location = "Near: " @story.locationCity + ", " + @story.locationState
end
%>
<%= @location %></p>
<% if (user_signed_in?) && (current_user == @story.user) %>
<%= link_to 'Edit', edit_story_path(@story) %> |
<%= link_to 'Delete', @story, method: :delete, data: { confirm: 'Are you sure?' } %> |
<% end %>
<%= link_to 'Back', stories_path %>
어디에서 문제가 있습니까? – uzaif
@uzaif, 내가 발행 된 정보를 인쇄하고있는 라인에 문제가 있습니다. 내 코드에 문제가있는 위치를 보여주는 주석이 있습니다. –