title: How to use if statements as ruby injections in html?
body: <p>so what I started off trying to do was to perform an if statement within my html code where @events was defined in my controller:</p>
  
  <pre><code>&lt;% @events.each do |event| %&gt;
         &lt;% if event.starts_at.hour() == 9 %&gt;
         &lt;p&gt; &lt;%= event.name %&gt;
         &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>but obviously now after trying to load it, the program doesn't like this. (I am very new to ruby so I have to at least try these things out!) </p>
  
  <p>The error I am given when trying this is:</p>
  
  <p>C:/Users/Sarah/RubymineProjects/MyApp/app/views/calendars/_show.html.erb:49: syntax error, unexpected ')', expecting keyword_then or ';' or '\n' ...? &amp;&amp; event.starts_at.hour ==9 );@output_buffer.safe_append=' ... ^ C:/Users/Sarah/RubymineProjects/MyApp/app/views/calendars/_show.html.erb:52: syntax error, unexpected keyword_end, expecting ')' '.freeze; end ^ C:/Users/Sarah/RubymineProjects/MyApp/app/views/calendars/_show.html.erb:54: syntax error, unexpected keyword_end, expecting ')' '.freeze; end ^ C:/Users/Sarah/RubymineProjects/MyApp/app/views/calendars/_show.html.erb:364: syntax error, unexpected keyword_ensure, expecting ')' C:/Users/Sarah/RubymineProjects/MyApp/app/views/calendars/_show.html.erb:366: syntax error, unexpected keyword_end, expecting ')'</p>
  
  <p>Why is this happening? Is it because my _show.html.erb is a partial being used in my main.html.erb? 
  How would I go about doing this?</p>
  
  <p>Here is an attempt I made with my Pages controller. The html file is called _show.html.erb which belongs to another controller, but it is rendered into the main.html.erb file belonging to the Pages controller.</p>
  
  <pre><code>class PagesController &lt; ApplicationController
  
    #before_action :require_customer, only: [:main]
  
    def home
  
    end
  
  
    def main
      @events = current_customer.calendar.events
  
      def mon900(event)
        if(event.day()==1 &amp;&amp; event.hour()==9)
          @mon900 = event
        end
      end
    end
  end
  </code></pre>
  
  <p>and I called this method in the html like this:</p>
  
  <pre><code>&lt;% if @mon900 %&gt;
      &lt;p&gt;do something&lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Am I on the right track? I have only been learning Ruby for a week and so am obviously not familiar with the framework and syntax. 
  Thanks!</p>