Rails Scopes – Putting a Limit on JSON

Ruby on Rails Logo

My Conditions project has two wireless “conditions” sensors sending air temperature and humidity to a Rails server every minute. Now I want to display the current temperature and humidity on a CharlieWing. The first task is to get the Rails server to stop dumping the entire history of temperature readings into the JSON file returned when I request it. I’d like to implement this with URL parameters so I can request (for example) http://192.168.2.2/measures?station=1&limit=1 but my attempts so far have failed. As usual, I’m going to put my pedant hat on and get this right.
Continue reading “Rails Scopes – Putting a Limit on JSON”

Ruby on Rails One-to-Many Associations

Ruby on Rails Logo

It’s incredible how often, with technology, we pour hours into learning something new only to have forgotten it by the time we need to do it again. If it’s only a little thing then a bookmark will cover it. If you’re lucky to find a blog post that covers exactly what you want — again a bookmark is all you need. But what if you pull together information from all over and need it preserved in one coherent source for later use? I use my own blog to do a memory post. Continue reading “Ruby on Rails One-to-Many Associations”