Chris Oliver

Joined

291,530 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Stripe Subscriptions: Duplicate Customers

Did you have local: true on the form_with?

Posted in How can I integrate Amazon Native Ads

Well, that's sorta good. We know it's running and it's hitting the URL so both of those tags are running.

Do you have a link to a page that you can share with this on it? I was going to poke around and see what's going on. I haven't ever used their ad widgets before myself so I'm not sure what to expect.

Posted in How can I integrate Amazon Native Ads

Hey Alex,

I haven't actually played with this myself, but you may need some adjustments to make this work with Turbolinks, although you also might not.

Generally if you're putting script tags in the body, Turbolinks will make sure they get executed on the second pageview. You can put a console.log inside the tag that sets all the variables there and see if it prints out when you navigate around.

Since this stuff looks like you're putting it inside the body tag, you should be fine but you may have to make some adjustments.

Can you try putting a console.log in that first script tag and make sure that one prints out each time?

Posted in Let's Encrypt Error on Hatch

One thing you can try is to run these two commands on your server:

sudo apt-get clean
sudo apt-get update

Posted in Let's Encrypt Error on Hatch

Sometimes the repositories get out of sync or have errors like this. If you give it a bit of time, these usually get cleared up in an hour or so.

It's just something DigitalOcean does to reduce the bandwidth your server's use, so they keep a clone of the repositories in their datacenter. Their repositories just have a temporary issue there.

Posted in Multiple File Uploads with Shrine Discussion

Sounds like you're missing the routes for Shrine. Make sure this is in your routes file. https://github.com/gorails-...

Posted in Sending Emails with SMTP and Sendgrid Discussion

Adding an attachment in your mailers is just as simple as doing:

attachments['file-name.jpg'] = @model.upload

The right side should just a be a File-like object that Rails then assign to the filename in the email.

Hey Muneeb,

Check out this post and the comment on solutions for that. https://stackoverflow.com/a/15101745/277994

Posted in Stripe Subscriptions: Duplicate Customers

The #card-element error comes from you trying to run this on every page regardless if the field is on the page. You'll want to add some JS to check if the element exists, and if it does not, return.

document.addEventListener("turbolinks:load", function() {
  if (!document.querySelector("#card-element")) {
      return
    }

    // rest of your code
}

As long as it helps get your app launched sooner than later! 🤓

As long as you write good scopes and before_action methods in your controllers you should be fine. I generally don't recommend doing multi-tenancy unless your data is truly separate.

Multitenant apps generally act like truly separate databases so the user data never gets shared.

Yeah, I'm not quite sure actually what benefit you get out of going with multitenancy right now. If you plan on making the Student side of things combine data from each Teacher, you're not really building a multi-tenant app. You may want to consider just building a regular Rails app and associating records to teachers like you normally would.

Yeah, so Account would have the subdomain to identify the tenant.

UserAccount

  • belongs_to :user
  • belongs_to :account

You sound like you're trying to accomplish something different though, maybe not something exactly like a normal multi-tenant app.

The question is really what are you trying to accomplish here? Are you just looking to have each teacher's data separate from other ones? If so, then just make the Teacher the tenant, and Students don't really matter. They probably would go inside the tentant because they're specific to the teacher. They would login on the Teacher's subdomain.

Posted in assign_attributes not working

Subtle one! Good catch.

Sometimes I have done virtual attributes on the User (like "user[card_"+field+"]")) and other times just directly accessing the param. It doesn't really make a difference which way you go, but the virtual attributes can make it nice to assign all the fields and then do the saving in a method on the model rather than in the controller.

Hey Muneeb,

Just create a new file in the /etc/nginx/sites-enabled directory. Name it whatever you want, just not default since that's already being used.

If you use the gem, you have to use the asset pipeline for it. This is what I would recommend anwyays. The asset pipeline is perfect for these things. Any reason why you're avoiding using the asset pipeline?

So generally you want all your account related things to be outside the tenant.

User
Account / Tenant / Organization / Team (whatever you call this)
UserAccount (join table between the two to give Users access to accounts)

Everything is goes inside the tenant since those should all be private.

Or, you can put User inside the tenant and require users to login from the correct subdomain. This is how Slack works where you can use the same email to create many accounts. They're not global so you don't have a central account.

Kinda depends on what you want to accomplish. If you want users to be signed into all their tenants at once, putting the model outside the tenant is best.

Posted in Stripe Subscriptions: Duplicate Customers

Hey Nick,

That's sure weird! I think what it looks like is happening is that your Javascript is submitting the form twice.

You can tell because the first POST to /memberships hasn't finished before the second one starts. And that's why the logs are mixed together and you have those two UPDATEs on the user. They're processing almost at exactly the same time.

You should do some debugging on your Javascript to figure out why it's executing twice and that should fix the problem.

Posted in SweetAlert integration

Hey Michael,

Not quite sure what's going on there, but any reason you're not using the gem? It already hooks into the standard rails data-confirm stuff and makes this seamless and you can customize the colors and buttons like usual.

Posted in Disaster recover plan?!

I should clarify that. If your uploads are up to S3, any thing that happens to your server won't affect those files (which is good). You can also setup your S3 to back itself up to another bucket, or another service if you wanted.