How to auto-reload changes in a Rails Engine?
Asked Answered
P

2

10

I have a Rails 4.1.0 mountable engine. In the engine's application_helper.rb:

module MyEngine
  module ApplicationHelper    
    def test123
      "test123"
    end    
  end
end

The method is in the dummy app's view general/index.html.erb view:

%<= test123 %>

This works. However, when I change the string returned by def test123 and refresh the browser, the new string is not displayed.

Of course, restarting the web server in the dummy app shows the new string.

So the question is, how to reload the engine's files without having to restart the web server?

PS. I am preferably looking for a way to do this using Rails itself, or a specific gem that solves this problem (but not the generic gems like Guard, Spork etc. although if all else fails, I will consider those too.)

PPS. There are similar questions on SO, but I have tried them all (even though they are for Rails 2.x, 3.x), and they have not worked for me.

Phonoscope answered 24/11, 2013 at 7:14 Comment(0)
H
2

You should explicitly require dependent helpers:

# engines/my_engine/app/controllers/my_engine/application_controller.rb

require_dependency "my_engine/application_helper"  # This is a key point!

module MyEngine
  class ApplicationController < ::ApplicationController
    helper ApplicationHelper
    ...
Humes answered 29/10, 2014 at 14:32 Comment(0)
P
0

you can use some thing like zeus which is helping a lot in watching project files for changes except in some cases when you change the configuration files it doesn't work and needs to be manually restarted.

but overall in most cases this works more than awesome

Palacios answered 12/12, 2013 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.