Ever since I started building Rails app, I’ve dreamt about one day building mobile apps in Rails. Well, that day has finally arrived, thanks to Turbo-iOS!
With Turbo-iOS you can basically point an iOS app to your backend Rails app, it handles the native navbar functionality and pushing views however the content of those views is simply your backend web app.
Build high-fidelity hybrid apps with native navigation and a single shared web view. Turbo Native for iOS provides the tooling to wrap your Turbo 7-enabled web app in a native iOS shell. It manages a single WKWebView instance across…
Using Git Aliases can make you feel like you have superpowers!
It wasn’t until recently that I discovered Git Aliases, they are so handy that I seriously don’t know how I lived without them. These are two that I use every day now.
git config — global alias.add-commit-push '!git add -A && git commit -m "$1" && git push && git status'
Once the alias has been added you can now add, commit and push all on one line.
git add-commit-push "Add, commit, push in one line!"
git config --global alias.new-branch '!git checkout -b "$1" && git add -A &&…
This GitHub Action lets you easily attach GitHub commits and pull requests to a Trello card simply by including the card number in your git commit message.
GitHub Issues is such a great tool for software development teams. However if the rest of your company is already using Trello, then you are faced with the decision whether to stick with Trello or switch to GitHub Issues.
The upside of sticking with Trello is that it’s already familiar for non-developers so it’s easy for other team members to submit bugs or feature requests. …
I’ve used lots of different WYSIWYG editors in the past, most are clunky or produce messy HTML, but Quill.js is a pretty light weight option that actually works fairly well. The following will show how to use Stimulus to create a Quill editor as well as add some missing table functionality.
Note, the table module is only available in the upcoming 2.0.0 release, so you’ll need to add the latest dev version to be able to use it.
yarn add email@example.com…
CanCanCan is a powerful authorization library that allows you to authorize! the current_user for an action, as well as restrict records only accessible_by their current_ability.
authorize! :index, Classroom
@classroom = Classroom.accessible_by(current_ability)
Once you start using StimulusReflex, you’ll soon need to utilize the accessible_by in your reflexes to only obtain records permitted for the current_user as well. …
This Rails strategy lets you lazy load your CanCanCan abilities so you only load them when needed helping improve overall performance.
I love CanCanCan, it’s a powerful authorization library for Rails initially created the Ryan Bates and later adopted by the Rails community to support and maintain. It’s my default authorization gem for all my Rails projects.
I also like to follow STI pattern for authentication, for example having a base User with Admin, etc subclasses. To go along with these user types, I usually define UserAbility, AdminAbility, etc to encapsulate all specific user’s abilities in one file.
In a previous post I wrote how to Lazy Load Form Fields In Rails Using StimulusReflex. I like Stimulus and StimulusReflex both a lot, paired together they are incredibly powerful set of libraries for Rails.
For example, let’s say you have a form where you want to pull in a list of GitHub repos for a user so they can display them on their profile.
Loading this data from GitHub’s API can take a couple of seconds depending on the number of repos the user has, so rather than delaying the entire form from loading we can instead load them asynchronously.
The initial /app/views/users/_form.html.erb would look something like this.
This Rails pattern provides a flexible way for clients to specify whether they want nested resources includes in the API response simply by passing a flag as a parameter to the endpoint.
For example if you were building a simple blog, you would get Posts with Comments by calling posts.json?comments=true, however calling posts.json or posts.json?comments=false would return Posts without Comments.
Being a long time fan of Bootstrap, I liked that Quasar follows a lot of Bootstrap conventions for padding, columns, etc. They also have a larger suite of controls than the Ionic Framework including a nice timeline and messages component.
Unfortunately I found their solutions for handling a responsive grid of cards to…