Activity
Hey Thomas,
This is a good question. The basic trouble (if I'm understanding correctly) is that when you delete the file, you're re-rendering the partial but there is no UploadImage for that new element that you rendered.
I think you're correct in that you should be doing a new UploadImage(elem)
in the destroy.js. My guess is that class isn't accessible globally, causing that line of code to fail. One of the issues with the JS response from a remote call is that it often hides the errors that happen, so it's harder to debug.
If it actually is that the UploadImage class isn't globally accessible, then you should need to simply change the class UploadImage
to class @UploadImage
to make that globally available.
Give that a shot and see if that works for you!
Also this is an okay solution for debugging that JS that you return: https://www.alfajango.com/blog/rails-js-erb-remote-response-not-executing/ You basically inspect the response in Chrome, run the JS manually in the console, and fix the errors. Not ideal, but hey, it works.
Exactly. Add a new server block to the nginx config, setup your new database, deploy your other app, and voila! Should be all you need to do.
Posted in Stripe EU Vat
Hey Jacob! That's a really good question.
I don't know a whole bunch about VAT, but it sounds relatively easy so long as you're collecting this information at the time of checkout. It sounds like you might want to simply collect their country and then store a hash somewhere that contains all the VAT information for the country. When the user types in their country, you can match it against that hash (or records in the database if you want to update them there), and then you could charge the appropriate VAT.
This is a bit outdated, but may not take too much work getting back up and functional. It looks like it can tell you if you need to charge VAT which is nifty. It basically just stores an array of the countries and checks against that.
https://github.com/phusion/eurovat
Is VAT a standard rate for all transactions regardless of country? Sadly I don't know very much about it at all.
Posted in Sharing on Twitter / Facebook callbacks
Oh that's a good idea. The only really reliable way verify they shared would be to make the post through your app. Would you be good with having the users connect their Twitter and Facebook accounts with OAuth for that?
Posted in Deploy ActionCable Discussion
Roughly the first line tells Passenger to group app the websocket connections together for this app (in case you had multiple websockets apps on the same server) and the second line is saying that you can have an unlimited number of clients connect through websockets.
More info here: https://www.phusionpassenge...
Posted in Integrating Mailboxer with Apartment
Oh this is an interesting one. I believe you'll have those tables in all the tenant schemas because of the way the gem works, but you'll be able to exclude the Mailboxer models so that they operate outside of the tenants like you would do with your User model for example.
Check out this section and see if that helps. I believe you'll want the migrations to run as they have already, then just add all the Mailboxer models to this config. https://github.com/influitive/apartment#excluding-models
Posted in Exporting Records To CSV Discussion
Something like this? You'd basically create your own string to add to the CSV as the first column.
csv << ["#{user.name} #{user.email} #{user.coupon.code}", user.id]
Great question. So generally in a mobile app, you'll have to have that token stored somewhere. Basically if the token exists in the cache in your mobile app, you can then assume the user is logged in. If it doesn't exist, assume they are logged out.
There is an extra exception that sometimes tokens can expire and aren't permanent. If they do have time limits on them, you can store that in the mobile app along with the token to determine if it is still valid or not. If they don't, you can just request any endpoint and know that if it fails, you're going to need to request a new token.
Does that help?
Perfect! I was going to say, it sounds like your title method or something on the MissingArticle isn't accepting the number of arguments that the ActiveRecord model is. Glad you figured it out! :)
If you're using Turbolinks 3, it should be on by default. It only shows if the request takes more than a certain period of time I believe, so you may just not be seeing it in development. You might try tossing in a sleep 5
into your code to see if it shows up.
More info on it here: https://github.com/turbolinks/turbolinks-classic#progress-bar
Posted in Deploying Sidekiq To Heroku Discussion
Great question. I would actually remove the queues you listed and then Sidekiq will process everything by default. You don't really need to separate out queues until you have so much background work happening that it makes sense to separate and prioritize them.
@disqus_Uh95M6FOYo:disqus @disqus_4UMLsxjaNb:disqus Enjoy! https://gorails.com/episode...
Good work man! It looks like it turned out pretty clean and simple. :D
The free solution is alright. It provides a semi-secure connection. You're securely connected to Cloudflare, then the request gets forwarded to you, but at that point it is unencrypted. There is a possibility that someone could access the traffic coming from Cloudflare to your app that's unencrypted.
If you do need something that's fully encrypted, you'll want an SSL cert running on Heroku. That's the route I usually take because we want full encryption (and sometimes don't use Cloudflare).
Your cheapest option would be to use Cloudflare's flexible SSL. You wouldn't have to pay for the $20/mo for SSL hosting on Heroku that way. There are some other SSL options that Cloudflare provides but I think they cost money. https://www.cloudflare.com/...
Also most places require you to purchase an SSL certificate, but you may want to check out Let's Encrypt which let's you get a free SSL certificate. https://letsencrypt.org/
Posted in Nested form and models?
I think the has_many relationship seemed good. Anything more complex sounded like it would be overkill unless you've got some other requirements to add in there.
Posted in Nested form and models?
This seems alright to me. Have you looked into the cocoon gem for making the form?
Posted in URL Based multi tenancy
Hey! Are you looking to do multi-tenancy based upon domain? If so the apartment gem is what you'll want. It can separate the database out by domain and provides some helpers for that. https://github.com/influitive/apartment
I did an episode on the Apartment gem using subdomains but you can modify that to use domains instead of subdomains. https://gorails.com/episodes/multitenancy-with-apartment
The readme for the gem shows all the relevant bits you'll need to change to support domains instead of subdomains.
As for making usernames at the root instead of on /users, you'll need to make a custom route.
resources :users
get ":username", to: "users#show"
The second route will take the /samsoft
route and send it to the users show action. You'll need to make sure this route goes at the end of your routes file so that if you ever add something like /help
it wouldn't think that "help" was a username.
Hey John!
If you're using Bootstrap, I sometimes use their collapse / accordion JS lib for this kind of thing: http://getbootstrap.com/javascript/#collapse
http://getbootstrap.com/javascript/#collapse-example-accordion
Thanks man! :)
I'll have to do an episode on jQuery.turbolinks soon. Also Turbolinks 5 as well since that should be coming out in the near future.