Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Displaying previous score in current record

Oh wait, I think that's it! You're actually calculating the the beginning of week from today every single time you access it. Instead of using Date.today, I think you probably want to use the column saved to your record, probably week_start. That should fix it!

Posted in Displaying previous score in current record

I was going to suggest something similar.

def last_score
  user.weekly_performance_reviews.order(week_start: :desc).last
end

This would do sorting based upon the week start (assuming that was a date) but your suggestion there would work as well since it's ordering by the IDs as long as those count up.

You might have something else going wrong then if records are getting overwritten. I'm not too sure about that. Any other info you have as to what might be going wrong?

Posted in Displaying previous score in current record

Oh I see. That makes sense.

So you probably need to be able to find the previous weekly performance review from any record right? Are you setting week_start to like the Sunday or Monday beginning of each week?

Posted in Lots of trouble using LESS in a paid theme.

When you use Less or Sass (especially when variables are involved) you won't really be able to use the require section at the top for the asset pipeline. At that point, you basically just have to use the regular @import functionality of Less/Sass to do those imports.

Can you find the file that contains the border-top-radius method? It should be defined somewhere in one of those files and then when you find the file, you'll want to put that require at the top and just make sure it's included before any of the files that would be using it. I think that should do the trick for you.

Posted in Displaying previous score in current record

Interesting. Let's see if I'm understanding this right, are you looking to compare two WeeklyPerformanceReview objects?

Posted in CoffeeScript Class + Partial remotly reloaded + Binding

Awesome! Glad that worked. :D

Also just found some notes on their recommendation of which version to use: https://github.com/turbolinks/turbolinks#should-i-use-turbolinks-5-or-turbolinks-classic

I think you'll be fine using either one. I've been meaning to upgrade GoRails' Turbolinks to 5.0 but just haven't had the time yet. I'll have to do a screencast on that.

My guess is that 5.0 is okay to use, but they still haven't released some features like the iOS and Android wrappers for it which were the main purpose for 5.0. Feel free to use it though as it should also have a progress bar and will be the version that you'd need to use in the future.

I believe the main change between 2.5 and 3.0 was the addition of the partial replacement stuff. Shouldn't cause any issues when upgrading, but just note that the partial replacement functionality is getting removed in 5.0. They realized that it adds a lot of complexity for very marginal benefit and decided to remove it to keep things simple.

The video on LiveCoding.tv was mostly just exploring the partial replacements in Turbolinks classic, but since that's getting removed, it probably won't be too helpful. It sucks that their player doesn't work! I had trouble with it too and was disappointed with the site.

Posted in CoffeeScript Class + Partial remotly reloaded + Binding

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.

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

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]

Posted in How to know if the user is logged in, in a mobile app.

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?

Posted in Refactoring with the Null Object Pattern Discussion

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.

Posted in Background Workers with ActiveJob and Sidekiq Discussion

@disqus_Uh95M6FOYo:disqus @disqus_4UMLsxjaNb:disqus Enjoy! https://gorails.com/episode...