Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Refresh browser automatically when view (and related) files change

A lot of my work (in Rails) actually centers around the views, images, SASS/CSS and Coffescript/Javascript files and I'd love to have a solution that refreshes the browser, whenever I make a change to any of this type of files. A little like autotest or watchr but for 'design' tasks.

I've looked at watchr and fs-event, which seem to provide related functionality and look around the web, but I couldn't find any ready solution yet. Did I miss something? Hard to believe that this wouldn't have been done yet — the tools clearly exist.

Assuming that a tool like this really doesn't exist, I'd like to have crack at writing my own solution. So if you have some advice on what to consider, where to have a look at interesting projects etc. — I'd appreciate that as well.

Update An example workflow would look like this:

  1. Start "watcher application" in terminal
  2. Rails server starts if it's not running
  3. Browser window opens automagically pointing to rails server
  4. I go and change a change some HTML in a view
  5. The browser refreshes automatically
  6. I update some CSS
  7. The browser refreshes automatically
  8. I add a new JS file
  9. The browser refreshes automatically

Cheers!

like image 974
polarblau Avatar asked Jan 19 '11 14:01

polarblau


3 Answers

From your description I would think that LiveReload would do the trick for you.

You'll need to change the .livereload file to only reload the browser on specific file change but it's all covered in the readme (scroll to the configuration section)

There's also XRefresh that can do pretty much the same stuff but I've never used it.

like image 172
Pierre-Luc Simard Avatar answered Oct 20 '22 16:10

Pierre-Luc Simard


Try Guard::Livereload. It will automatically reload your browser when 'view' files are modified.

For more information (and a demo) see: http://asciicasts.com/episodes/264-guard

like image 24
Wilhelm Avatar answered Oct 20 '22 17:10

Wilhelm


Perhaps you're looking for something like this project?

https://github.com/logankoester/autorefresh

like image 3
jmcnevin Avatar answered Oct 20 '22 16:10

jmcnevin