As I test and update my pages/controllers, it'd be awesome if a page refresh would cause them to reload. Seems like I have to restart apache (or reload it) using the rake tasks to make that happen. I feel like I MustBeDoingItWrong. Am I?
Rick
The easiest way to do this without needing to modify Calatrava is to use an out-of-process reloader. I've been using rerun (https://github.com/alexch/rerun).
rerun 'rake web:apache:start' --pattern '**/*.{coffee,js,html,css,sass,scss,haml,yml}'
And that'll automatically restart apache whenever any of those files change. It's not instant, but it's better than nothing.
There is an easy and better way to do this. I have been doing it on my projects. I should probably compile and submit it as a patch. Here is what you need to do. (Similar to what James suggest below, but bit more targeted)
Add "filewatcher" to your Gemfile
bundle install
Create a file auto_update.rb (or whatever name you fancy) in your root directory. And add contents like
require 'filewatcher'
FileWatcher.new(["kernel/", "shell/"]).watch do |filename|
puts "Recompiling file " + filename
system "node_modules/coffee-script/bin/coffee --compile --output /<path_to_app>/web/public/scripts #{filename}"
end
This would mean that it would compile the coffeescript to the js file automagically whenever the file changes. You may have to add this for multiple directories by listing them in the comma separated way.
The best part is that apache will pick up changes in js files upon a browser refresh so you won't have to restart server or any of that, unless you change something that you have set up a file watcher for.
In an ideal work, we would like the rake tasks with calatrava to be exposed to do the individual setps and then call that rake tasks instead of compiling coffeescript files ourselves. In that case, the watcher can start off with apache and world will be beautiful again. :)
Let me know if you face issues with this.