Valium 0.4.0 released, now with 100% more English

Comments

Just a quick update about Valium 0.4.0. In 0.3.0, I enabled support for extracting attribute values from associations (a la User.posts[:id]). That was awesome, but as it turns out, not too compatible with 3.0.x associations.

The solution

I figure this is going to be the tip of the iceberg in terms of potential gotchas, so before we get anywhere near to 1.0, I’m pulling out the [] syntax, but adding a new alias: values_of. This is just to help code read better – the functionality is exactly the same. So now, instead of:

    # Don't do this. It won't work anymore. :(
    User.where(:name => 'ernie')[:id]
    User.where(:name => 'ernie')[:id, :email]

You will write:

    # Do this:
    User.where(:name => 'ernie').value_of :id
    User.where(:name => 'ernie').values_of :id, :email

Sorry for the inconvenience. Of course, you’re always free to alias these to whatever you want, in your own code. Just don’t blame me if things randomly blow up.

And Pratik, if you’re reading this: Yes, you told me so.

comments powered by Disqus