【发布时间】:2017-06-28 13:40:30
【问题描述】:
我正在尝试在我的 Rails 项目中按类别过滤帖子,我正在使用 Camaleon CMS。我的基本要求是只显示特定的帖子。
例如,仅显示属于“水果”类别的帖子?
这是我使用的代码:
<% current_site.the_posts(current_theme.get_field("recent_post_type")).latest.limit(current_theme.get_field("home_qty")).decorate.each do |post| %>
<!-- PORTFOLIO ITEM -->
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 text-center discussion-bot-box">
<h4><%= post.the_title %> <span>(299)</span></h4>
<p><%= post.the_content.html_safe %></p>
</div> <!-- /col -->
<% end %>
【问题讨论】:
-
你可以使用
current_theme.the_posts.where(category: 'fruits')
标签: ruby-on-rails ruby ruby-on-rails-4 camaleon