venerdì 28 ottobre 2011
I decided to use a virtual attribute to do this, as it seemed the most elegant solution, so I wrote this in my model:
And this in my controller:
However, trying to send this data to the controller resulted in a "1 error(s) on assignment of multiparameter attributes" error.
The solution I found after some search was this one:
mercoledì 20 luglio 2011
So, the solution was to resize the Macintosh HD partition. I booted my Mac from the Lion install DVD (you can burn it from the installer package, just search google to know how to do it), went into disk utility, checked all partitions for errors (this was necessary because I wasn't able to resize them otherwise) then I resized only the Macintosh HD partition shrinking it by some GBs.
After this, I ran the installer again and installation started smoothly.
domenica 19 giugno 2011
Today I decided to verify if Machinist could be a good replacement for Factory Girl. In our project, we have a big problem with Factory Girl: even if you tell her not to hit the database, using the Factory.build method, if an object has associations, these are saved on the DB. And this causes a huge slowdown in specs using factories. We've been using Factory Girl for nearly two years, and if we could find a way to stop him hitting the DB, we could really have a huge improvent in our test suite running time.
To verify if Machinist could perform better, I set up a basic rails app. Look at this example:
If you do a tail -f log/test.log and you run this spec, you'll see something like this:
The Factory.build method has to save dependencies on the DB to set the foreign keys on the objects and validate them.
Let's try with machinist:
This time, running tail on the test.log file and running the spec, doesn't shown any DB hit, and of yeah, we have a green test.
I verified this also by putting a debugger line after the validation and inspecting the DB from within the debugger after the validation has run - with FactoryGirl, it revealed an Address object saved on the DB, while with Mechanist it didn't.
I still haven't looked inside machinist to show how it handles this, but I'll do it soon, so keep in touch!
giovedì 10 marzo 2011
If you wonder where is this code coming from, it's directly from the rails console code.
venerdì 28 gennaio 2011
martedì 18 gennaio 2011
You're sure you've already installed the library or dependency or whatever, but in a different path from the standard one (in this example I'm talking about PostgreSQL installed via the graphical installer instead of the ubuntu apt repo); so you issue the command
gem install pg -v0.9.0 --with-pg-dir=/opt/PostgreSQL/9.0
And you get this error message: invalid option: --with-pg-dir=/opt/PostgreSQL/9.0
What's the problem? You need to separate options with another pair of dashes:
gem install pg -v0.9.0 -- --with-pg-dir=/opt/PostgreSQL/9.0
And everything will work.