I am using rails 4 and trying to incorporate some simple javascript in my application. I believe the asset pipeline is working because I wrote alert(Hello!);
in the file pages.js.coffee, which is in my javascripts folder, and the alert worked on the web application. However, when I try to write something in the pages.js.coffee file like
`var today = new Date(); var hourNow = today.getHours(); var greeting; if (hourNow >18) { greeting = 'Good Evening!'; } else if (hourNow > 12) { greeting = 'Good Afternoon!'; } else if (hourNow > 0) { greeting = 'Good Morning!'; } else { greeting = 'Welcome'; } document.write('<h3>' + greeting + '</h3>);`
nothing happens in to the application.
Furthermore, I am trying to incorporate this javascript in my HTML file using <%= javascript_include_tag "pages" %>
Could I also include the code using <script src"javascripts/pages.js.coffee></script>
Thanks for any help!