问题描述
此案涉及三个模型
- 一个{_1}},具有多个...
-
stream
,其中has_many ... -
clips
在comments
内,我正在渲染streams/show
,它具有两个用于对片段进行排序的按钮(“最近”和“最新评论”)
clips/all_clips
<div class="flex m-1">
<%= link_to recent_clips_path do %>,<div class="...">Recent</div>
<% end %>
<%= link_to most_comments_clips_path do %>,<div class="...">Most comments</div>
<% end %>
</div>
<% if @stream.clips.exists? %>
<% @stream.clips.each do |clip| %>
<%= render 'clips/clip_small',clip: clip %>
<% end %>
<% end %>
范围可以正常工作,它们是:
clip.rb
相关路线:
scope :recent,->{ order("created_at DESC") }
scope :most_comments,-> { where('comments_count >= ?',1).order("comments_count DESC") }
这是我遇到的问题,我不知道如何将其从resources :clips do
collection do
get :recent
get :most_comments
end
end
渲染为部分内容:
clips_controller
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)