I am unsure how to call a model method from a controller
In Event controller query is ran in
class StaticPagesController < ApplicationController
def self.all_published()
events = 'SELECT user_id FROM events'
where("dotw = DAYNAME(curdate())")
end
end
Page_controller
def index
@published_posts = Event.all_published.paginate()
end
View
<% if @published_posts.any? %>
<ol class="microposts">
<%= render partial: 'shared/feed_item', collection: @published_posts %>
</ol>
<%= will_paginate @published_posts %>
<% end %>