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