railsjazz / rails_live_reload

Live Reload for your Rails app. The easiest way to increase your productivity.
https://www.railsjazz.com/
MIT License
318 stars 8 forks source link

scripts installed, firing but not on changed data #37

Closed dvodvo closed 4 weeks ago

dvodvo commented 4 weeks ago

Hello, Initially, I attempted to configure as follows on a partial (which is used on 3 pages, convenient!)

RailsLiveReload.configure do |config|
  config.watch %r(app/views/placements/_placement_status.html.erb)
end if defined?(RailsLiveReload)

The page does show:

<script defer="" type="text/javascript" src="/rails/live/reload/script"></script>
[on open_k.html.erb]
<script id="rails-live-reload-options" type="application/json">
  {"files":["/Users/deploy/r/fbapp/app/views/placements/_placement_status.html.erb","/Users/deploy/r/fbapp/app/views/placements/open_k.html.erb","/Users/deploy/r/fbapp/app/views/ops/_nav_ops.html.erb","/Users/deploy/r/fbapp/app/views/layouts/shared/_footer_public.html.erb","/Users/deploy/r/fbapp/app/views/layouts/application.html.erb"],"time":1723812789,"url":"/rails/live/reload"}
</script>
[on open_b.html.erb]
<script id="rails-live-reload-options" type="application/json">
  {"files":["/Users/deploy/r/fbapp/app/views/placements/open_b.html.erb","/Users/deploy/r/fbapp/app/views/placements/_placement_status.html.erb","/Users/deploy/r/fbapp/app/views/ops/_nav_ops.html.erb","/Users/deploy/r/fbapp/app/views/layouts/shared/_footer_public.html.erb","/Users/deploy/r/fbapp/app/views/layouts/application.html.erb"],"time":1723812728,"url":"/rails/live/reload"}
</script>
[on placement_status.html.erb]
<script id="rails-live-reload-options" type="application/json">
  {"files":["/Users/deploy/r/fbapp/app/views/placements/_placement_status.html.erb","/Users/deploy/r/fbapp/app/views/placements/placement_status.html.erb","/Users/deploy/r/fbapp/app/views/ops/_nav_ops.html.erb","/Users/deploy/r/fbapp/app/views/layouts/shared/_footer_public.html.erb","/Users/deploy/r/fbapp/app/views/layouts/application.html.erb"],"time":1723812582,"url":"/rails/live/reload"}
</script>

I assumed things were fine. However...

Looking at other pages, this script is generated for any page. This is somewhat unexpected.

<script id="rails-live-reload-options" type="application/json">
  {"files":["/Users/deploy/r/fbapp/app/views/roleuniqs/index.html.erb","/Users/deploy/r/fbapp/app/views/roleuniqs/_roleuniq.html.erb","/Users/deploy/r/fbapp/app/views/roleuniqs/_form.html.erb","/Users/deploy/r/fbapp/app/views/ops/_nav_ops.html.erb","/Users/deploy/r/fbapp/app/views/layouts/shared/_footer_public.html.erb","/Users/deploy/r/fbapp/app/views/layouts/application.html.erb"],"time":1723813394,"url":"/rails/live/reload"}
</script>

But the major issue is: no updates driven by the console are firing as expected (the network tab does not show anything after the MiniProfiler script); they are evident only when refreshing the page.

Thus there is something I misunderstand.

I understood what when I proceeded to an edit of the partial file. It showed up! Thus, the state of an element on the rendered page will not change; is it possible to effect the update on change of a turbo_frame_tag ?

While I am at it, I fail to understand two other, possibly related elements:

  1. default initialiser has # config.enabled = Rails.env.development?
  2. suggestion that Gemfile include gem "rails_live_reload" in development block.

Is this not supposed to work in production?

dvodvo commented 4 weeks ago

I understand, after digging in that this is not a substitute for broadcasting. my bad.