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?
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?
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!
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.
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:
Hmm. That sounds like everything. Looks like I have a lot of things to catch up on.
echo 'gem "newrelic_rpm"' >> Gemfile.d/newrelic.rb
# create config/newrelic.yml, copy from Newrelic site
RAILS_ENV=production bundle install
A more complete installation of Apache Flood (http://httpd.apache.org/test/flood/building.html)
svn co http://svn.apache.org/repos/asf/httpd/flood/trunk flood
svn co http://svn.apache.org/repos/asf/apr/apr/trunk apr
apt-get update && apt-get install autoconf libtool libxml2-dev make libapr1-dev libaprutil1-dev
./configure --disable-shared --with-libxml2
Stopped here, as I get errors when trying to compile.
I hope this helps someone.
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:
- rails g model Foo name
- rails g devise Foo
- rails g scaffold Foo –skip
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.