Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to instantly see the edit to the erb file?

Tags:

ruby

erb

sinatra

I am using Sinatra and erb on Passenger/Apache. Every time I made edit to the erb file, I have to restart Apache and refresh in the browser.

Is there any way to edit the file and sinatra can instantly update it? I mean simply by clicking the refresh button in the browser can one view the update?


Conclusion:

If you are in dev on sinatra, you can use shotgun or SinatraLoader.

If you are using Passenger, you can create an empty file: tmp\always_restart.txt

like image 986
SwiftMango Avatar asked Nov 16 '25 21:11

SwiftMango


2 Answers

Yes, you can use Sinatra::Reloader.

Sinatra::Reloader

Extension to reload modified files. Useful during development, since it will automatically require files defining routes, filters, error handlers and inline templates, with every incoming request, but only if they have been updated.

like image 118
Simone Carletti Avatar answered Nov 19 '25 13:11

Simone Carletti


You can use Shotgun for that: https://github.com/rtomayko/shotgun

Shotgun

This is an automatic reloading version of the rackup command that's shipped with Rack. It can be used as an alternative to the complex reloading logic provided by web frameworks or in environments that don't support application reloading.
like image 36
Nicholas Pufal Avatar answered Nov 19 '25 13:11

Nicholas Pufal