A few months back, I wrote something about my service object adventures to handle extraction of a business logic from a Rails model or controller. Recently, I got introduced and experimented on the concept of policy object. Policy objects are pretty much just like service objects. In fact, from what I understand, policy object is actually…
Category: Code
Code
How To Time Travel Using ActiveSupport TimeHelpers
by Kat Padilla • • 2 Comments
So I needed to test “time”…quite literally. I needed to test some time-related validity logic in Rails. I read that in Rails 4.1, ActiveSupport::Testing::TimeHelpers was added to make it easier for everyone to withstand the test of time. Err, I mean to test time. No disrespect to TimeCop, I know it has its own advantages, but the built-in…
Code, Toys & Games
Time-Lapse Video Generator Using Raspberry Pi
by Kat Padilla • • 2 Comments
So, I’ve been tinkering with my Raspberry Pi for the past couple of days. This weekend, I started with my time-lapse video generator using Raspberry Pi and its camera module. Taking snapshots is easy because RPi has a built-in raspistill command: raspistill -hf -vf -x -o melody.jpg There are many options which you can find here. When I connected the camera…
Code, Toys & Games
Setting Up Raspbian on Raspberry Pi
by Kat Padilla • • 0 Comments
The very first thing that I did was to download an OS that my Raspberry Pi will use. There are many options like NOOBS and Ubuntu Mate but everyone’s sold with Raspbian so I chose it as well. Setting Up Raspbian on Raspberry Pi After I’m done downloading the OS here, using was not as easy as transferring it…
Code
Service Object Adventures
by Kat Padilla • • 0 Comments
I have read a lot of Rails articles and most of them always tell you to keep your Rails controllers skinny. It sounds so easy but it’s really not. As the cliche goes, “it is easier said than done.” In real life, requirements get complicated. Controllers and models get longer and longer and you need to do something about…
Code
Yet Another Rails Adventure
by Kat Padilla • • 0 Comments
I’ve been playing with storing and setting dynamic stuff in Rails because I’ve been repeating similar codes over and over and it’s becoming annoying. Luckily, I found a pattern and started to experiment from there. In a nutshell, this is what I’m trying to achieve: Create dynamic re-usable sessions from a param[:filter] if it exists. For…
Code
STI
by Kat Padilla • • 1 Comment
As I dive into more Rails-y stuff, I was told about the concept of Single Table Inheritance. (s/o to MJ for introducing me to this!) This Rails design pattern is characterized by using a single table that stores data from multiple models that inherit from a base model (the parent class of STI) which inherits from ActiveRecord::Base. (Whew!) OK,…
Code
ActiveRecord::Store for Settings
by Kat Padilla • • 0 Comments
Using the config.yml it’s fairly easy to store app settings that we want to be able to change quickly between environments. That is cool until your boss tells you that they need to be able to change it on the app itself a.k.a. on the fly. The initial advice that I got for this kind…
Code
Meet Ernie
by Kat Padilla • • 0 Comments
Note: This blog post is 2 weeks late. We (as usual, I was with Mark Steve) joined this event called Textify and we were given a month or so to think of an SMS-based project and build it. It was hosted by Chikka with the help of Smart DevNet to promote the use of the recently launched Chikka SMS API platform. At…
Code
Handling Global Exceptions for APIs
by Kat Padilla • • 1 Comment
I was able to teach myself (this includes a lot of Google-ing and asking) how to do some basic exceptions handling in a Rails app that uses GrapeAPI. I’ve experimented with Sinatra before for a hackathon so I was a little familiar with some of the concepts already but there are still things to learn (a lot actually!).…