这是用户显示他们应该显示的视图。..
编辑(我已经稍微更新了这篇文章,你可以在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>
所以表格(部分)加载得很好,但是当我发帖时,无论是购买清单还是销售清单都没有出现。我检查了数据库,它们正在与列中指示种类(销售或购买)的条目一起创建
以下是表格:
<%= 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
谁能帮我吗?我还需要什么吗?嗯