Error Messages For Your SJR Templates Using BetterSJR
Why does debugging SJR templates have to be so hard?
It’s no secret that trying to figure out what’s causing an SJR template to fail can be a nightmare. The main cause of this pain is simply the lack of error messages when something goes wrong.
When SJR templates fail, you are treated to deafening silence rather than the helpful Rails error explanations that you are accustomed to. This means that you, the developer, have no idea where to look and what is to blame.
For all of the niceities that the Rails framework provides, it’s clear that the SJR debugging experience is lacking. So why does Rails leave us high-and-dry in this regard? Shoudn’t we expect something better?
Simply showing error messages would help a lot.
With error messages guiding the way, identifying and fixing common JS runtime errors such as undefined variables or functions becomes much easier.
That’s exactly what the BetterSJR gives you.
Here are some samples of the gem in action:
Example #1 - jQuery isn’t loaded
Example #2 - Typo in a variable name
Whereas before nothing at all would show up in the console, with BetterSJR there are now helpful log messages pointing you toward the source of your error(s).
Try it out!
Click here to view the project’s repository.