Chris Oliver


248,110 Experience
19 Lessons Completed
272 Questions Solved


Posted in URL Based multi tenancy

@Howard OLeary, if you want schema based multitenancy, sure. It's still the best bet for that.

I more often do row-based multitenancy. That's what we do in the template. The ActsAsTenant gem is pretty good for that.

Posted in Searching and partial keyword matches

Probably need to do some more work with pgsearch. 👍

Weird, you'd think they'd prompt for the username / password!

RSS is working just fine for me. What do you mean it no longer works?

Posted in How to create a button with a file upload action

Hey Nelson,

You should be able to listen to the change event on the file field. That fires anytime the input value changes. Use that to fire off the form submit.

Posted in Question about twitter clone

Hey Rick,

Absolutely. If you can imagine it, you can build it. For following hashtags, you'd want to create a model for the Hashtag and then very similar to following users, you'd create a model to join the two records. I'd call it UserHashtag or something and just belongs_to :user and belongs_to :hashtag

Posted in New website design!

Oh simply because that's what TailwindUI was using and I wanted to ship the site instead of porting their examples to Stimulus. I forgot I still need to convert those!

Posted in Gem for making user groups

Typically I just create a model called Group and a model called GroupUser that keeps track of which user is in which groups.

No gems for it that I know of since everyone tends to implement it differently.

Pundit is great for handling permissions and Devise is great for authentication pieces. The Group and GroupUser models will let you connect the two.

Hey Camilla,

I almost always use the Devise wiki page to not require the current password to update their account. That would make it so the user wouldn't have to know their password to update.

And this would make for a fantastic screencast... 😎

One trick I like is using signed GlobalIDs. This way you can reference any model. Your form could list all the guests and employees and submit their SGID over to the booking to be transformed to the proper record.

They must be signed global IDs to prevent tampering though.

Definitely looks like a good solution if you can't use Javascript. No Javascript is sure going to cause a lot of frustrations for every other feature.

Generally for staging, you can just deploy the app to a single server to save money compared to the production fully load balanced cluster.

Posted in CRUD on attribute in N/N join table

You should loop through @user.user_items.includes(:item) instead so you can access the quantity without an extra query. The includes will load the items records efficiently so you aren't doing any N+1 queries.

Posted in CRUD on attribute in N/N join table

has_and_belongs_to_many does not allow you to access the join table, and therefore it's very rarely used.

Instead, you just want to define a has_many :through association.

class User
  has_many :user_items
  has_many :items, through: :user_items

class UserItem
  belongs_to :user
  belongs_to :item

class Item
  has_many :user_items
  has_many :users, through: :user_items

This way you can interact with the join table and add things like quantity.

Posted in Refreshing the page with form errors

Turbolinks is getting a major update now that was released and I believe is going to fix this. One of their main improvements was to fix the forms.

Posted in Login with Facebook Discussion

There are easily like 100+ OAuth providers so we just have a few of the most popular ones built-in and made it easy for you to add any of the other available ones.

Posted in Login with Facebook Discussion

Hah, you beat me to answering it. I was going to say, we made it so that by default any omniauth libraries you add will be automatically handled by the callbacks controller so there's nothing to do unless you want to extend the integration.

Posted in How do I override the default link_to helper?

Great! Congrats on your first gem. 🎉

There's nothing special you need to do for deploying Webpacker with Capistrano as it's built-in to the Rails assets:precompile step. The only thing you need to do is make sure that NodeJS is installed and in your PATH when deploying.

You don't want to install NVM as the root user. It should be on the deploy user, same as rbenv. Your code always runs and deploys under the deploy user so you want to avoid root.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.