Chris Oliver


247,160 Experience
18 Lessons Completed
271 Questions Solved


Posted in Inviting Users with devise_invitable Discussion

Nothing special for that really. If you have two models, you have current_user and current_admin because Devise separates those out. Devise Invitable has a polymorphic invited_by column, so you can pass in any object for that.

Your invite code would look like this:
User.invite!({ email: '[email protected]' }, current_admin)

Posted in API Authentication with an OAuth Provider Discussion

I just add a constraint around it in my routes.rb.

Posted in Rails Application Templates Discussion

Rails application templates only work for generating new apps, so you can't get any updates on an existing app with them.

You can read through the changes and apply them to your app though. It's a manual process instead but it will get you updated.

Posted in Jumpstart pro configuration question

Jumpstart Pro doesn't currently have any marketplace functionality. You could add it yourself separate from the payments that are built-in to Jumpstart Pro.

You'd use the stripe connect omniauth gem to let the users login with Stripe and then you would need to setup payments through Stripe Connect on your account that run payments on the user's connected Stripe account. It's been a while since I've done any of that.

That's something I'd love to add in the future, but not sure when I'll be able to get to that.

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Really old post of mine that's relevant here. I bet it's the cookie domain you need to update in both apps.

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

It's been quite a while since I've deployed it. If it's crashing on User.first then I assume you need to maybe run a rake task to setup a User or create one in the Rails console first? Not real sure.

Posted in How to write System Tests in Rails Discussion

All the methods can be found in their docs:

Posted in Open Closed Principle Discussion

I definitely think you should raise some error, it doesn't have to be NotImplementedError. The main reason you want to do that is because it provides a clear explanation why something didn't work.

You don't want to assume people are going to read the docs and implement every method correctly on the first try. It's very likely that won't always be done perfectly. Raising the error helps guide the developer on how to properly implement their subclass which is very helpful. I don't use and IDE, but if there are benefits there, then that's another reason that makes it more intuitive to use for other developers.

Posted in Admin Interfaces with Administrate Discussion

Yeah, should be. I have been using my own fork of it too.

You'd just use the Heroku action as the last step I believe:

Posted in Tracking Metrics with Ahoy and Blazer Discussion

Yeah, should be able to set it up without Users. That's what guests are anyways, they don't have a User. You can always ask on the GitHub issues for it and get tips from the author. 👍

So what I would probably do here is actually:

resources :milestone do
  member do
      post :activate, to: "milestones/activations#create"
        delete :deactivate, to: "milestones/activations#destroy"

Then you can have a app/controllers/milestones/activations_controller.rb that handles them. That's great for separating out the logic from the main CRUD, and your routes aren't too complicated.

I'll often make a singular resource for things like this too.

resources :milestone do
  scope module: :milestones do
      resource :activate

Works a bit better if you're doing like resource :advanced_search or something.

In your case, DELETE /milestones/1/activate doesn't make sense, and you'd want the destroy route to be DELETE /milestones/1/deactivate so it's more intuitive. And that's why I'd probably write the custom routes instead of resources in this case.

I think it's fine for you to make some non-standard actions here.

Are these actions changing the Milestone record or are they change an Activation / Completion records associated to a Milestone?

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Helpy is great! Deployed it via Hatchbox a little while back and it keeps improving.

I think you can probably use the API to create users after they're created in the main app.

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

If they both use Devise, you can sync the user accounts between the two databases and then set the cookies to store on * so they're automatically logged into both. The apps would need to share a secret key base for that since it would be decrypting the same cookie.

That's the ideal so you don't have to have the users go through any process.

You can do omniauth and make your main app where the user logs in the provider and then every other app can be the client. That will work too. You might be able to tweak it so they don't have to approve and it automatically approves the OAuth request so it is more seamless.

Posted in How to write System Tests in Rails Discussion

Yeah, it'd be a great way to test and make sure your Vue app was integrated correctly with the Rails app. You can also look into things like Jest to test just the JS independently, without Rails.

Posted in Sending Emails with SMTP and Sendgrid Discussion

You'll need to use their API to do that. Check out this gem:

Shouldn't be too bad. You'd want to figure out what it means to abandon the cart. Is that a cart that was last created 1 hour ago that wasn't checked out?

Then you'd want a cron job to look for those carts every X minutes or so, and then send the email. You'll probably want to mark those carts as "abandonment email sent" or something so you know to filter them out next time.

The cron job running every X minutes should always find ones created one hour ago and incomplete, so that the emails get sent out regularly.

Posted in docker screencast?

Probably at some point. I don't have any specific plans for it yet.

Yep, check out the JWT from scratch episode instead. That one will work just fine and you won't have to depend on other maintainers.

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.