我不确定如何从控制器调用模型方法
在事件控制器查询中运行
class StaticPagesController < ApplicationController
def self.all_published()
events = 'SELECT user_id FROM events'
where("dotw = DAYNAME(curdate())")
end
end
页面控制器
def index
@published_posts = Event.all_published.paginate()
end
看法
<% if @published_posts.any? %>
<ol class="microposts">
<%= render partial: 'shared/feed_item', collection: @published_posts %>
</ol>
<%= will_paginate @published_posts %>
<% end %>