Activity
Well if you've done that, you also need to salvage the old file uploads by moving them from one the old releases folders and move them into the new public/system folder that's being symlinked. That's likely why your image still don't work. Kind of a pain as well.
If you are just using test data, you can try reuploading an image, doing a new deploy, and making sure that image still works.
Doh, yeah they do that sometimes. At some point soon I'm going to swap out Disqus with my own comment system.
Basically those methods with !
at the end of them, they actually mutate (or modify) the variable in place. Without the !
a map will create a new array in memory so you'd have to full arrays in memory, and you could discard the other one after the method completes. Using the !
methods should improve your object allocations because they won't be creating new arrays in memory.
Posted in Pull data from another table in a lookup
@Alan, they're actually badges, so you get a badge at 1, 3, 6, 12, and 24 months but only after you cross that threshold. Going to be doing similar things for answering questions and whatnot. :D
@Jacob, yeah for sure! The editor is https://github.com/NextStepWebs/simplemde-markdown-editor which I like quite a bit. It was easy to setup, but unfortunately doesn't provide any way of doing @mentions unfortunately. Guess I may have to build my own editor at some point instead.
Posted in Pull data from another table in a lookup
Yeah, there's a lot of changes, I'll be announcing it all shortly!
Posted in Pull data from another table in a lookup
@Alan, I added a reactions feature so you can give kudos to other people just like on Github issues. :D
I think you're generally going to struggle optimizing the number of allocations in this because your operation happens on every single user balance. It's going to allocate a ton of objects no matter what you do since you're loading every active one.
One optimization you can make is to pluck the active user IDs and query by that rather than loading up all those objects. I would also test to see if the in place mutation methods improve performance like so:
def self.all_users_gold_balances
gold_gateway_id = Gateway.find_by(currency: "GLD").id
active_user_ids = active_users.pluck(:id)
user_balances = Balance.where(gateway_id: gold_gateway_id).includes(:user).where(user: active_user_ids).pluck('balances.amount', 'users.account_number')
user_balances.map! {|balance| array << {account_number: balance[1], gold_balance: balance[0].truncate(3)} }
user_balances.sort_by! {|hash| hash[:account_number]}
return user_balances
end
Yeah that should work. What cache key is that referencing in your logs?
You could include the filter and role in your cache key and save them as separate caches.
I would be somewhat careful with that because if you have a lot, then you're just filling up the cache storage with stuff that's likely to get blown away and you won't get any benefits from caching. Compiling a list of small cache snippets is super fast, so you might consider just not caching the list, but cache each individual item instead. The compilation of everything will be fast enough and can save you on some cache storage space if you notice bloat saving all the different copies.
If you've got a real Actionmailer config setup to hit a real smtp server, you can have it send real emails in development. If they aren't arriving, then you will want to double check your configuration to make sure that it's authenticating correctly and you see the emails being sent from your email provider logs.
Yup, you can either use JS to hide / show functionality or you can also include the role in the cache key if you want. That will create caches for each role meaning you'll use more cache storage, but can cache each version separately. I'd still recommend using JS to hide / show things so you only have one cache per item.
You have to make sure that you symlink the paperclip uploads folder each deploy so your files don't get lost. They create a folder on your server and then every deploy the Rails app is deployed to a new folder, meaning you lose those old files.
Add this to your config/deploy.rb
and it will symlink the directory each time so your files won't disappear.
set :linked_dirs, fetch(:linked_dirs, []).push('public/system')
I may or may not cover Sidekiq in that episode. The trick is as long as you use ActiveJob, there's no difference if use sucker_punch or Sidekiq to power it. They'll work exactly the same except that with Sidekiq you just need to make sure the Sidekiq process is running. ActiveJob provides that nice abstraction layer on top so that your code is exactly the same and you can swap background workers easily.
Nothing too special, just toss them in a Bootstrap modal and that's it. :)
LOL! It might have been cached or something, awesome that it's working now! :D
Haha no worries! Want to upload the file for me to look at what you've got?
Posted in Pull data from another table in a lookup
@Jacob, the markdown preview is different than the server side renderer so things are slightly different sometimes.
Yeah, that's my bad on these. They have -part-X appended to the end of the filename instead of updated numbers on the beginning because I did a weird exporting process on these compared to my normal ones.
The missing semicolons are okay, the browser handle that just fine. The missing ) doesn't sound right, because that would actually cause the JS to break if that were the case. That could be breaking your code by adding that in, or you've got an extra opening ( somewhere.
I updated the file with the semicolons for ya: https://github.com/gorails-...
Posted in Pull data from another table in a lookup
Agreed Jacob!
And yeah you're right about the HABTM table name. The thing about HABTM is that you don't get to ever interact with that table in the middle...so imagine you needed some meta data, like a quantity of the product in each venue...well you're SOL with HABTM. If you have an explicit model as a join table, and do has_many through, then you can add extra columns in like a quantity and do a whole lot more with it. In most cases I find it's better to be explicit about that join table than using HABTM for that reason. Guess I should do an episode on this!