Discover more from The Art && Science of Ruby
Replacing Ruby on Rails
Finding a framework that does what I need whilst keeping me happy
I really don't like the Rails asset pipeline and Rails itself is huge and unwieldy - as well as becoming generally unsuitable for the type of apps we build nowadays.
So I've been searching for an alternative.
Unfortunately, most of the ruby web-server frameworks do not impress me. They seem dry, technical and spark no joy as I'm playing around with them (Camping and Sinatra being notable exceptions - but they are both tiny).
However, I may have found the solution.
On the back-end, I've rediscovered Grape. I used this many years ago and remember really enjoying it1. Grape is a tiny framework focused purely on building HTTP APIs - it does a load of parameter validation up-front, and even better, it generates documentation, in Swagger format, for the consumers of that API.
And on the front-end, I was playing with Bridgetown. Bridgetown grew out of Jekyll - a static site generator. You define a layout and write your blog posts in Markdown, then tell Jekyll to build your site. It then generates all the HTML and you can rsync the lot up to your server. Fast and secure.
But Bridgetown has become a lot more than that. Firstly, it uses esbuild (which I know nothing about) and yarn internally to handle your assets. It uses Roda internally so your generated site can also include dynamically generated pages2. But, it also comes with a number of predefined configurations that you can install, which add to the build process.
One of these configurations is Ruby2JS, which I hadn't heard of before.
So it looks like I've got all the pieces I need to replace a Rails stack. Bridgetown to generate my front-end, Ruby2JS and Lit to define what gets shown and handle user interactions, and Grape to actually protect and serve the data that my application needs.
The next step is to try it out - which I'll be writing about next.
1 Although, at the time, I dropped it because I was building a large Rails app and having the two different styles in the same system felt odd.
2 Of course, this means you're no longer just generating HTML, so you need to run the Roda process in ruby on your server
3 A high performance ruby interpreter that I know nothing about, and as it's Oracle, I've kind of avoided
() to a method call or include
super in an inherited method.