0
다음은 사용자가 표시해야 할 위치를 보여주는 사용자보기입니다. ..RoR : 내 마이크로 포스트가 왜 보이지 않습니까?
편집
<section>
<div id= "purchases">
<%= render 'shared/micropost_form_purchase' %>
</div>
<div id="sales">
<%= render 'shared/micropost_form_sale' %>
</div>
</section>
<div id="purchases list">
<ol class="microposts">
<%= render @purchases unless @purchases.nil? %>
</ol>
</div>
<div id="sales list">
<ol class="microposts">
<%= render @sales unless @sales.nil? %>
</ol>
</div>
그래서 양식 (파셜)이 잘로드 (내가 업데이트 한이 게시물은 약간 당신은 RoR: How can I get my microposts to show up?에서 볼 수),하지만 나는 할 때 게시물에 하나 하나, 구매 목록이나 판매 목록이 나타나지 않습니다. ,
<%= form_for (@micropost) do |f| %>
<div class="field no-indent">
<%= f.text_area :content, placeholder: "What's something else you want to buy?" %>
<%= hidden_field_tag 'micropost[kind]', "purchase" %>
</div>
<%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>
또한
<%= form_for (@micropost) do |f| %>
<div class="field no-indent">
<%= f.text_area :content, placeholder: "What's something else you want to buy?" %>
<%= hidden_field_tag 'micropost[kind]', "sale" %>
</div>
<%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>
: 나는
여기 양식있는 데이터베이스를 확인하고는 종류 (판매 또는 구매 중 하나)를 나타내는 열에서 항목과 함께 생성되고있다 다음은 users_controller.rb의 표시 부분입니다.
def show
@user = User.find(params[:id])
@micropost=Micropost.new
@microposts = @user.microposts.paginate(page: params[:page])
end
여기에 microposts_controller.rb
def show
@micropost = Micropost.find(params[:id])
@microposts = Micropost.where(:user_id => @user.id)
@purchases = @microposts.where(:kind => "purchase")
@sales = @microposts.where(:kind => "sale")
end
이 사람이 나를 도울 수 있습니까? 내가 필요한 다른 건? 흠 당신이 원하는 결과를 얻고 확인하기 위해,
에 대해 반복합니다? 그게 무슨 뜻 이죠? – BigBoy1337
즉, 컨트롤러에서 @sales = @ microposts.where (: kind => "sale")'를 설정하면 해당 쿼리는 결과를 반환하지 않습니다. 그래서 나는 콘솔에 가서 @microposts 변수를 확인하고 그 일이 무엇인지 살펴 봅니다. –
괜찮아요 @ microposts 정의가 작동하지 않는 것 같습니다 – BigBoy1337