Using ActiveRecord with an unchangeable legacy database schema poses some interesting challenges. Most of the work is a new style (for me) of composing adapters to make non-Rails stuff work within Rails' conventions.
ActiveRecord uses the database's native
NULL to indicate an unset attribute [Ruby's
nil]. This becomes a problem when the column definition enforces
NOT NULL on columns that you may or may not be setting values.
So what's up with TextMate and replace string in selection?
i.e. why is it not there in the find dialog?
So you've spent hours putting together some sensible data for your tests in a bunch of tediously crafted YAML files, and you're staring at a blank development database. If only there were an easy way to slip that data from the test database back into development . . .
Once you go through the pain of setting up SQL Fairy (CPAN, yikes!), you can be designing your database visually with OmniGraffle in collaboration with other non-Railsy folks, and then generate your Ruby migration and stick it directly into your Rails project.
I was talking to someone (can't remember who) at Rubyconf and
they brought up
#local_variable. This method shows
you the names of all the local variables in scope.
Funny, I don't remember this function, and if I did know it, I
had forgotten about it. So, I fired up
irb and type
it in to see what I get back:
local_variables #=> ["_"] x = 5 #=> 5 local_variables #=> ["_", "x"]
Hmmm, this is interesting. I know there is a variable in
that contains the value of the last expression, but it is not easy to
remember. But, it looks like
_ will do the same thing.
I'm always doing math expressions where I need the value of the previous
expression. So now, instead of up-arrow and add to the equation, I can
5/7.0 #=> 0.714285714285714 2*_ #=> 1.42857142857143
Of course, you can you this for any irb expression, and best of all, it is a variable name I can actually remember. :)
For you Perl folk, you may be familiar with the term autovivification. In essence, that is where an empty data structure gets automatically created if it is referenced, but does not exist.
For example, consider a hash. Let's say we want a two dimensional hash such that we can write:
points = Hash.new points = 5
The problem here is that
points must return
a hash, and this hash is in turn accessed with the key '2'. It
would be the same thing if we wrote:
1 2 3
points = Hash.new tmp = points tmp = 5
Well, RubyConf 2006 is nearly upon us and it looks like the state of Texas is going to be well represented by six Austinites.
Those attending are:
- Jim F.
- Hal F.
- Wayne W.
- David B.
- Robert R.
Wayne must have made some kind of deal with a Leprechaun, because he was able to purchase a ticket just this week from zdennis. I bought mine ten minutes before the announcement that registration was open, and consider myself lucky since registration was only open for two hours.
Just wanted to welcome everyone to our Ruby website, and give it a little test drive.
Thanks to Mars for putting this together, with some help from Wayne, and thanks to Wayne for providing the hosting.
Our server set-up is as follows:
We're starting out with three mongrels in the pound. Time will tell if more are required.
The original plan to serve static files from a separate virtual host has been nixed by my impatience.
See: The Workings r2 for updates since this article.
We're finally on-line! I love progress.