Simple AJAX and Rails Tutorial

It’s been a while since I’ve posted anything but I’ve been extremely busy coding my face off. The upside of that is I’ve been learning a ton of new stuff and I have a lot of things I want to write about.

Today I’m just going to go over a quick tutorial on how to use AJAX to send requests to functions in your Rails backend. The problem I kept running into was calling a function that is in a different controller than the view I’m calling it from.
Continue reading

Background Tasks & Rails – A Sidekiq Example

This post involves a little bit of everything–queuing (Sidekiq), JSON, API calls, redis, database manipulation. Enjoy!

The latest feature I am pushing to Dotawithme is listing the players by who is currently online. This is an oft requested feature (with good reason – DOTA players are impatient) but I wasn’t entirely sure what the best way to go about this was.

Of course I couldn’t just hammer Valve’s Steam API or I would quickly hit my daily limit. This means I need to create a background process to run at set intervals and update the database accordingly. There are many different gems to help your Rails app out with this and I settled on Sidekiq (‘Sidekick’) because it’s fast and (supposedly) simple to use.

Continue reading

On Scope, Lambdas, & SQL Queries

Adding MMR (match making ranking) filtering to Dotawithme has been an oft requested feature on Reddit so I finally decided to tackle the issue. I wasn’t exactly sure the best way to go about it but in the end I decided I wanted to put rankings in a range of 500. I thought the best way to do this was to use a dropdown menu with a variety of ranges to select from (ie: 1001-1500 or 1501-2000).

Continue reading

Adding Private Messages in Rails Apps

I keep adding features to The latest and probably largest feature yet has been private messages. I looked around and there are quite a few gems out there that will do this for you, but they haven’t seemed to be updated in a while. After trying one out (and failing to get it to work properly) I decided it would be a good challenge for me to write my own.

Continue reading

Writing My First Gem for Rails

If you aren’t familiar with gems they are the Ruby on Rails equivalent to WordPress plugins. I wanted to learn how to write my own so I found this great tutorial at Quick Left.

I had an idea for a gem that I wanted to make quickly so I didn’t build the exact same gem as the tutorial. Instead I just wanted to make a simple gem so I could lookup info about a visitor on a website.

Continue reading