December 29, 2011 § Leave a comment
Note: I wrote this up a few weeks a go, but didn’t publish it for some reason. It is a touch out of date since Rails 3.2 RC1 was recently released, but should be close enough to give you a good idea on how to get up and running on Rails master.
I wanted to play with the latest and greatest for Rails, which at the time of writing is 3.2.0.beta (RC 1 is now out). This means building and installing the rails gem locally. It took me a good while to figure out how to get everything working, so I figured I’d throw it down here for future reference… and for anyone else running into the same problems I did.
I am using rvm to isolate my different gem set ups, so as not to get random version conflicts. These are the lists of commands with notes I ran to get everything up and running:
# create a new gemset to use with rails master rvm gemset create rails-master rvm gemset use rails-master # this is where I am going to put all of the git repos cd ~/src # Rails 3.2.0.beta requires the most recent (as in master) # versions of arel and journey git clone git://github.com/rails/arel.git cd arel gem build arel.gemspec gem install arel-*.gem cd .. git clone git://github.com/rails/journey.git cd journey gem build journey.gemspec gem install journey-*.gem # now get Rails cd .. git clone git://github.com/rails/rails.git cd rails # install all of the Rails pieces, # i.e., ActiveRecord, ActiveSupport, etc... cat RAILS_VERSION | xargs ruby install.rb # check to make sure you are riding the correct rails ruby -r 'rails' -e 'puts Rails::VERSION::STRING'
You can get just the commands in a gist too.
December 27, 2011 § 1 Comment
Rails 3.2 RC1 was released last week and it announces some pretty cool new things. One of those things is something that I have played with building out myself (tagged logging) and another is something I actually did (ActiveRecord Store). When I wrote my data-attributes gem, I was inspired to do so because I had a users table that had an ever-growing number of email permission checks. I never queried against these, and they made doing a
SELCET * FROM users; really painful to try and read. I decided to just throw them all in a serialized column and be done with it.
When I first read the release notes for 3.2 I had two thoughts go through my head.
1) Well, crap.
data-attributes is now dead and useless. (yes, I use <code> tags in my head)
2) Awesome, the solution I came up with for a problem I was having is the same one that the Rails team came up with. Maybe I might know a thing or two about what I am doing.
But as I started to compare the new ActiveRecord::Store with
data-attributes, I began to realize that my little project isn’t dead quite yet. The accessors generated by the store call with AR::S aren’t full attribute accessors. By this I mean they don’t go through
write_attribute before committing the new data to the serialized hash. This prevents you from intercepting the accessor call and doing some pre/post processing. You also don’t get default values as with other attribute accessors. Definitely not a huge deal in the least, but something to be aware of. AR::S does mark things as dirty though.
data-attributes does not do this as of yet.
As for the future for of
data-attributes, I think that it is actually dead in the long run. If I were to work on this problem more in the future, I’d probably do so by adding the AR::S instead of continuing working on