5 Followers
29 Following
20 Posts
If you use Zed and work with ERB templates in a Rails app, and would like to use erb_lint & htmlbeautifier to format them:
https://owaiskhan.me/post/formatting-and-linting-erb-files-with-zed
Formatting and Linting ERB files with Zed on save | Owais

I've been using Zed lately and liking it a lot. It's very performant, has a much better Vim experience, and also comes with good defaults. One place where it is not there yet is formatting ERB files. But there's a simple way to fix that.

Supercharge your app: latency and rendering optimizations in Phoenix LiveView - Dashbit Blog

LiveView’s unique integration between server and client allows it to drastically optimize both latency and bandwidth, leading to user experiences that are faster and smoother than any other client-server combo out there

Not sure how well known, but rails has a helper called token_list (also aliased as class_names).

Super helpful when you're writing conditional stuff a lot, especially HTML classes.

Very similar to clsx, etc. in the JS ecosystem.

Alias it to `cx` to make it even shorter.

#rails #tailwind

For anyone stumbling across this, I wrote a gem that you can just add to your app and start using: https://github.com/owaiswiz/vc_shortcut

I wrote a blog post recently about speeding up code reloading in Rails for a faster feedback loop while developing.

https://owaiskhan.me/post/improving-performance-in-development-on-a-big-rails-app

Might be a significant enough improvement if you've got a huge Rails app with lots of routes and making a request after doing a code change locally is very slow for you.

#rails #performance

Improving performance in development on a big Rails app

Slow requests in development are painful. They lead to slower feedback loops and decrease productivity. If you are working on a big Rails app, and you're encountering slow requests, especially after you make a change, there might be a simple way to make things fast

If you use VSCode and have a lot of View Components, configuring explorer.fileNesting might clean up your `app/components` in the explorer a lot:

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*_component.rb": "_${capture}_component_*.html.erb, ${capture}_component.html.erb, ${capture}_component.js, ${capture}_component_controller.js, ${capture}_component.scss"
},

#rails #viewcomponent #vscode

I've always felt rendering ViewComponent with Rails is a bit too verbose.

Especially if you have namespaces. E.g:

render(Admin::Navigation::Item.new(label: 'Example'))

I've used a helper to make it nicer on 2 projects so far:

vc.admin.navigation.item(label: 'Example')

Maybe make it into a gem?

(Might seem a bit over-engineered on a first glance. But it's something that might be called 100s-1000s of time on a page, so had to make sure it's fast enough.

#rails #ruby #ViewComponent