[LRUG] Best practices for javascript in Rails apps

Tim Cowlishaw tim at timcowlishaw.co.uk
Wed Jul 17 05:13:36 PDT 2013


Hi all,

I've just finished working on the first rails app I've started from
scratch in ages, and, took the opportunity to apply some of the ideas
from Matt Wynne's Hexagonal Rails talk and Avdi Grimm's Objects on
Rails book, in the process.

I've been really happy with the result - I've been able to make
changes with more confidence, and ship new features faster than I have
taking  a more rails-y approach to application architecture, and my
test coverage is vastly better.

Whoever, there's a rather nasty skeleton in the
"app/assets/javascript" closet in my app, as, while I'm aware of the
proliferation of javascript testing frameworks and tools, and
libraries for doing client-side models, data-binding, etc, I'm really
not sure how best to structure my javascript code in order to take
advantage of them (apart from throwing out the idea of server
generated views entirely, and writing a thick-client js app which
talks to an API, which I'm not keen on, as I'm a boring old
stick-in-the-mud who likes things on the web to have proper URLs)

Therefore, has anyone got any tips or tricks for writing maintainable,
testable, well-factored javascript as part of a rails application
which has reasonably complex client-side behaviour, but isn't a
one-page app? Links to talks / blogposts / example codebases also
gratefully appreciated!

Cheers,

Tim



More information about the Chat mailing list