Option to turn off rhosimulator reloading on require?

M Mark Bauer 3 years 7 months ago
1 2 0

In rhosimulator, every time a file is required, I believe it is reloaded.  I assume this is intended as a feature so that you can edit your code live, and see the changes,  but in the project I am currently working on, we have to use some class variables, and when the require happens, those class variables are overwritten (we would like them to persist).  When outside rhosimulator the code works as expected.  Is there a way to toggle off this functionality?

Thanks for any insight,

MAB

Please Register or Login to post a reply

2 Replies

J Jon Tara

Mark Bauer wrote:

In rhosimulator, every time a file is required, I believe it is reloaded. 

MAB

Why do you think that? I would think that would break almost any application. Is there some documentation that states this?

require is supposed to run the code in the required file only if it has not been previously required. Doing something else would fundamentally break just about every library.

I can't comment on rhosimulator, since I don't use it. (I only use official platform simulators, not Rhosimulator. I find it too far from a realistic environment.)

M Mark Bauer

My thoughts are based on testing I have been performing, here are screen shots of a sample app that I built to demonstrate what I am seeing. 

Simple test class
================

Controller usage
================

Given the above code, I am expecting to see 'test' for @test_var the first time, and 'Test round 2' upon refresh.  This however is not the case in rhosimulator.  The value for @test_var is 'test' every time.  When performed outside of rhosimulator I receive the results I expect. 
Rhosimulator test
=================

Win32 test
=================

The work around we have been using is to require anything with a class variable in application.rb, which eliminates the issue, but it would be nice if we could require in the files that are going to utilize the classes. 

The reason rhosimulator is desirable for my team is that it has the tools for live javascript, html and css manipulation.  If you (or anyone else) have a recommendation for an alernative  that had these tools for win32 we would be VERY interested.  We have tried using the dev port with chrome, but that did not produce the results we were looking for. 

Thanks for the response,

MAB

CONTACT
Can’t find what you’re looking for?