martes, 18 de enero de 2011

Soy un incompetente

Para variar, me pasan cosas. Cosas rarunas. Os cuento.

Trabajando con Ruby 1.8.7 y Rails 2.3.8 y un código como este presente en un observer...

game = Game.find(some_id)
tmp_letters = cositas_varias(game.letters)
game.letters = String.new(tmp_letters)
game.save


me encuento con que no se genera un UPDATE sobre el registro correspondiente de la tabla GAMES. De hecho, ese código está tan adornado con el único objetivo de entontrar la manera de hacer que ese UPDATE se ejecute. Y habiendo probado de todo, el UPDATE sobre la tabla sólo se producía si a game.letters le asignaba un string constante...

game.letters = 'quecojonespasa'

Lo más sorprendente (o no) es que la asignación

game.letters = String.new(tmp_letters)

produce que game.changed? sea false.

He leído aquí que algunos operadores que se ejecutan sobre atributos de tipo String hacen que efectivamente changed? sea false y que por tanto no se ejecute UPDATE alguno. Y efectivamente, avisando al modelo de que el atributo ha cambiado con

game.letters_will_change!

hace que changed? sea true y el UPDATE se ejecute.

Y esto me hace retrotraerme a cuando en C y C++ te tenías que preocupar de pasar una variable por valor o por referencia y de si se genera copia o no y tal y pascual... Y como no recuerdo que nada así me haya pasado anteriormente en ruby on rails... o he tenido mucha 'suerte', que me extraña, o en esta versión de Ruby y Rails algo cambia o soy un incompetente. Que va a ser eso.

¡Salud y rocanrol!

The old man was covered with tattoos and scars
He got some in prison and others in bars
The rest he got workin' on old junk cars in the daytime
They looked like tombstones in our yard
And I never seen him when he wasn't tired and mean
He sold used parts to make ends meet
Covered with grease from his head to his feet
Cussin' the sweat and the Texas heat and mosquiters
And the neighbors said we lived like hicks
But they brung their cars for pa to fix anyhow
He was veteran-proud tried and true
He'd fought till his heart was black and blue
Didn't know how he'd made it through the hard times
He bought our house on the GI Bill
But it wasn't worth all he had to kill to get it
He drank pearl in a can and Jack Daniels black
Chewed tobacco from a mail pouch sack
Had an old dog that was trained to attack sometimes
He'd get drunk and mean as a rattlesnake
And there wasn't too much that he would take from a stranger
There were thirteen kids and a bunch of dogs
A house full of chickens and a yard full of hogs
I spent the summertime cuttin' up logs for the winter
Tryin' like the devil to find the Lord
Workin' like a slave for my room and board
Coal-burin' stove no natural gas if that ain't country I'll kiss your ass
If that ain't country it'll hairlip the pope
If that ain't country it's a damn good joke
I've seen the Grand Ole Opry and I've met Johnny Cash
If that ain't country I'll kiss your ass

lunes, 17 de enero de 2011

Como broma ya está bien

Hace casi tres semanas que Gemma lanzó su nueva web. En ella ofrece sus servicios como consultora y analista web.

Puedo decir tantas cosas buenas de ella, que no sé por dónde empezar, y aunque no sé si es la mejor puedo asegurar que le pone toda su energía a lo que hace, que es una apasionada de su trabajo y que una vez que has trabajado con ella, no te deja indiferente: o la quieres o la adoras.

Por todo ello y por todo lo demás, tanto si tenéis la certeza de que necesitáis contar con los servicios de un analista web como si tenéis una mínima duda de que vuestra web podría hacerlo mejor, visitad su página (que, por cierto, la he hecho yo :o) y dadle un toque. Seguro que no os arrepentís.

¡Salud y rocanrol!

She's sun and rain, she's fire and ice,
a little crazy but it's nice,
and when she gets mad, you best leave her alone.
Because she'll rage just like a river,
then she'll beg you to forgive her.
She's every woman that I've ever known.

She's so New York and then L.A.
and every town along the way.
She's every place that I've never been.
She's makin love on rainy nights,
she's a stroll through Christmas lights
aAnd she's everything I want to do again.

She's anything but typical,
she's so unpredictable.
Oh but even at her worst it ain't that bad.
She's as real as real can be
and she's every fantasy.
Lord she's every lover that I've ever had!
And she's every lover that I've never had.