How to create a PORO model and use it in Rails Form Helpers

First off, I’ll start with our use-case:

We have a fairly simple form for an item with some complexity. It would have default values derived from the current_user‘s attributes but would still have the field on its own. Overriding it in Item model feels like overkill (and starts to be a violation of SRP) so we set out to create a PORO model for it. Full code and explanation below the fold.

Continue reading How to create a PORO model and use it in Rails Form Helpers


The same song has been playing for 2 hours now.
It’s sunny outside.
I’ve been working for 2 hours now.
The view of the pool from our window is calming.
We’ve been here for 32 days now.
I kind of like it here.

The plates have shifted.
It has been 10 months now.
But the boiling hot anger and tremors of disappointment are ever stronger.
It has been 5 years for me since I had an idea, though.
I don’t feel anything, because I knew this was coming.

I’ll stay here until I’m 30.
That’s when I plan to revisit my plans.
But now, I’m still 27.
So there’s nothing else to do but to execute.
I had an 8-year head-start.
Why do I feel like I’m so far behind?

Love Gaming. Hate Gaming.

I actually have a love-hate relationship with gaming.

  • I used to steal from my dad’s wallet just to play in the nearest playstation rental place (remember those?)
  • It started me poking around my computer and lead me to my understanding of computer hardware today.
  • Me and my brother have spent upwards of 10,000 pesos over the course of 4+ years on internet cards and ragnarok cards as well as countless hours playing various MMO games (Ragnarok then Khan Online then Flyff then Dekaron and a bunch of other MMOs that I’m forgetting.)
  • It started me into writing scripts for bots and exercised my nascent logic skills (which turned out useful for programming.)

I love playing games. But it just sucks so much of my time and attention, because it’s too interesting and I’m finding out that I’m a really competitive person (even when I claim that I’m not.) Especially if it’s a game that has infinite replayability and a grind component (e.g. most MMORPGs), I’ll be gone for a week.

I’ve been able to stave this off because I play it on a dedicated computer but mobile games are now the bane of my existence. The accessibility makes it hard to compartmentalize and it provides a “good enough” dose to tide me over.

I wish to find the middle ground. Something like, play only games on weekends. Or in the evening. Something like that. But I’m realizing that it _is_ _fucking_ _incredibly_ hard.

It’s either I don’t play at all, or I just play all the time.

And I’m slowly finding out that I might have to give up gaming altogether if I want to be at 100%.
I’m trying to come to terms with this realization.

Game over, huh?

Peer-to-Peer Psychological Easing

If you follow my sister’s blog, you’ll sort of glean that we have this family problem. (Which family doesn’t, right?)

Oh, didn’t catch that? Or don’t read my sister’s blog?
Oh well, cat’s out of the bag. *shrug*

Anyway, everything that’s going on with my family is actually the least of my concerns at the moment. I’m emotionally distancing myself from the issue, because the situation really needs someone level-headed and impartial.

This is not to say I don’t have emotions – I do. I’m not bottling it up. On the contrary, I just say it to everyone I know that cares, reputation be damned. The more I tell it to other people, the less intense it becomes.

I think “peer-to-peer psychological easing” should be a thing. You heard it first here!

Thoughts on RailsConf 2016 – ActiveRecord vs. Ecto: A Tale of Two ORMs by Brad Urani

Everything he showed can be done using AR. It’s not anymore the “established pattern” of using AR, but by all means it’s possible to achieve the same kind of results (e.g. moving validations to specific methods and using explicit queries instead of chainable scopes) but it requires more discipline – because Rails just spoils all Rails developers with all the conveniences that it provides, me included.

Maybe I’ll do an experiment one of these days of ripping AR out of Rails and using either Ruby Object Mapper or Sequel.

Unproductive June

So, I’ve gone off my rails in the past month when it comes to managing my time.
I feel like I’ve not been contributing as well and as much as I should be.

Everything was moving and I had to settle down before I started any routines again.
So, after a month of moving around, I think I’m finally ready to fire off and pick up my speed again (which is funny, because we’re watching The Flash lately.)

Things that I want to get back on track again:
1. Timeboxing
2. Budgeting
3. Gym
4. Diet

Hmm. That sounds like everything. Looks like I have a lot of things to catch up on.

Building and installing Apache Flood (or at least as far as I got)

A more complete installation of Apache Flood (

svn co flood
cd flood/
svn co apr
apt-get update && apt-get install autoconf libtool libxml2-dev make libapr1-dev libaprutil1-dev
./configure --disable-shared --with-libxml2
make all

Stopped here, as I get errors when trying to compile.
I hope this helps someone.

Globe’s GoSurf Plans Analysis

Pesos Mb Mb per peso Peso per Mb Days Mb per Day
10 40 4.000 0.250 1 40
15 40 2.667 0.375 2 20
30 100 3.333 0.300 1 100
50 350 7.000 0.143 3 117
50* 700 14.000 0.071 3 233
50* 350 7.000 0.143 7 50
99 200 2.020 0.495 30 7
199 500 2.513 0.398 30 17
299 1500 5.017 0.199 30 50
499 3000 6.012 0.166 30 100
999 5000 5.005 0.200 30 167
1799 10000 5.559 0.180 30 333
2499 15000 6.002 0.167 30 500

* Prepaid only

Some observations:

  • Prepaid have the best deal in terms of cost per MB with the newest GoSURF 50 promo. Useful if you need to upload/download in a pinch.
  • GoSURF 499 is best value for money for 30 day plans.
  • Because there’s a No bill shock protection cap on Php 1,500, it’s almost never worth getting the 1799 and 2499 plans.

Note to self:

Remove devise_for in routes.rb if you’re trying to generate a scaffold of an already existing model.

Steps to replicate:

  1. rails g model Foo name
  2. rails g devise Foo
  3. rails g scaffold Foo –skip
    1. This would result with the error: The name ‘Foo’ is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

Commenting the devise_for line in routes.rb will allow you to proceed with the scaffold.