David Stevenson's blog
Ask for Help
"How can I know all the descendants of a class in the superclass at load time in ruby? I want to create a scope for each subclass."
You can't.
"What popovers should I use?"
We've used at least these two before:
"What recurring billing system should I use?"
We've had good luck with BrainTree and Recurly.
Interesting Things
- backbone-forms is a plugin to backbone that provides model-based form views similar to rails'
form_forfunctionality. - EmberJS meetup will be Feb 21, at our new pivotal office!
Ask for Help
"pg gem version 0.12.2 seems to be leaving connections open sometimes after our application server is dead. This results in transactions that never finish. Anyone know what's up?"
Interesting Things
- Tracker released major UI updates on Saturday, and we're getting a lot of positive and negative feedback about it. Fear the change!
- If you change code that's part of the rails asset pipeline, it won't really take effect until you deleted the cached files and allow the asset pipeline to regenerate them. This is because the pipeline watches for changes in the input files, but not in the source code.
Interesting Things
require "psyche"; require "yaml"? WRONG! We've found you have to do them in opposite order or your parsing is "all screwed up".
Ask for Help
"Rubymine is excluding code in our gem's
spec/directory from being indexed, can that be changed?"
We assume this is an optimization, because most people aren't interested in anything from a gem except the lib/ directory. There doesn't appear to be a way to change this behavior.
"How can I override the gem version requirements on annoying gems in my project?"
We're trying to bring in rails 2.3.2 + rack 1.1.x, but rails explicitly requires the old version of the rack gem. Can we do something sneaky to change the requirements without forking and modifying the gem??
"Is there a good set of practices for exposing ActiveRecord models to JavaScript?"
Like using Backbone.js model support? Or maybe just straight #to_json on models and embedding them into HTML templates?
Ask for Help
"Is flash RTMP streaming a secure way to stream video so it can't be downloaded?"
We're using this with CloudFront + S3. But will it protect our content enough?
"RubyMine + rspec 2.6, why won't my focused tests run?"
We hoped this could be easily fixable by detaching the rspec gems and reattching them, but no luck with our usual fixes.
"MixPanel, is it a good tool for analytics and log analysis? "
Compared to normal analyics tools or splunk for log analysis?
"Anyone ever stubbed out 3rd party calls to a Thrift RPC service before?"
Is there a better solution than some sort of standard generic ruby stubbing & expectation tool?
Interesting Things
- Postgres is giving us some weird behavior on Heroku when we have column names longer than 27 characters. We think the
update_attributecalls are not being persisted but no errors are generated. - There are finally some viruses/trojans for mac OSX that are gaining traction. Careful what you download!
- The
net-ssh-telnetgem makes running a scripted batch SSH session pretty easy. This might be a good tool for you, if you want something much less complicated than capistrano or chef server for remote automation.
Ask for help
- We just upgraded one project from Devise 1.1 to Devise 1.2 and reported "many problems which blew up all sorts of stuff". It was bad enough we had to rollback. Are there others with failure or success stories for this upgrade?
- Can you rate limit EC2 nodes using an Elastic Load Balancer? We'd like to cap the amount of traffic that can be sent to an app instance. I'm thinking advanced use cases like this are probably why you run your own haproxy instead of using ELBs.
- How are people running database migrations in their engine gems? I know rails 3.1 promises to bring this to the table, but is there a backport gem we can use?
Interesting
- iOS 4.2 is out! We're looking forward to trying it on the iPad (finally).
Ask for Help
"We keep getting webrat thread exceptions running our integration specs with the rails integration runner: Thread tried to join itself. The error message varies with different versions of ruby 1.8.6 vs 1.8.7."
Anyone had this problem or know why?
"How do I skin an iphone mobile site to be the correct width so it's not 980px wide?"
<meta name="viewport" content="width = device width" />
*"We're trying to deploy some nginx configuration changes to EngineYard Cloud, what's the right way to do that?"
We've tried building custom chef recipes to solve this problem, but they run after nginx has already restarted, so are a poor solution to this problem. The better solution might be to check in configuration files into the application and symlink them into the nginx configuration directory using a before_symlink.rb hook in the /deploy directory.
*"We've got a
has_manyassociation where some of the child records are originally saved in an invalid state. When we later load the parent and ask it if it's valid, it returns true even withvalidates_associated. How can we get the desired validation behavior?"
Turns out that unloaded associations are not validated. Solution: load the association before calling .valid? on the parent. In general, you should also not create invalid objects, instead using a state variable to put them into a "draft" or "incomplete" state where they are still valid but not complete. Then remove that state and you'll see the errors required to finish that object.
Interesting Things
- When RubyMine 2.0.1 won't run your focused specs, try attaching rspec 1.2.9 to it rather than 1.3.x. It fixed this issue for one of our teams.
- Rubymine 2.0.2 came out today: can finally run focused contexts?! Also including bundler support! What's new
- We tried our Unicorn on EngineYard cloud: so far so good. It's still "experimental" but seems to work.
Interesting Things
- Be careful when extending classes from structs. Their superclasses are essentially anonymous classes, so reopening them can be difficult. If you attempt to reopen them by extending them from "the same" struct, it will actually be a different anonymous class.
Ever had an STI model but wanted the views and controllers to pretend like it all extended the base class? You can have rails change the params[] namespace that it uses like so:
form_for :user, @admin_user, :url => user_path(@admin_user)
Or you can be super-cool and use polymorphic routes:
form_for @admin_user.becomes(User)
The becomes method is part of ActiveRecord, and it actually creates a 2nd copy of the object with the same attributes and a different class (shallow copy). Due to this implementation, it has limitations so use it carefully.
- Upgrading to rails 2.3.3 breaks HopToad. This is related to filter_parameter_logging, and it's technically rails' fault. It has been fixed in 2.3.3 stable (which I assume will be released as 2.3.4). You can also fix it yourself with a one-line-patch. Personally, I'd wait to upgrade till 2.3.4 comes out.
Interesting Things
- One of our projects is using mechanical turk to match and normalize their ugly data. After building some automatic matching with little success, the group is simply using the template web interface. The task can be trivially decomposed into tiny tasks, and accuracy does not need to be 100% perfect, so it's a great fit. They only spent a few hours and have results already!
Interesting Things
pgrepis a sweet tool for finding processes. You can find all your mongrels, for example, without having the problems of runningps aux | grep ruby. It's in theproctoolspackage on most linux/unix operating systems. For example, on osx usesudo port install proctoolskill -482kills all processes in the group 482. This is great for killing all the children of a daemon likemysqlorbackgroundrb.psshows the process group id next to the process id.monitdoesn't have great support for figuring out what happens when a start/stop command runs. It can fail silently, for example. One (bad) way of debugging this is to addechoto dump debugging info to a temporary file before and after these commands. Rumor has it thatgoddoesn't have these problems...- we've heard a rumor that
Marshal.dump(object)uses a temporary file on disk! This would be slower than it needed to be. Perhaps this is to deal with dumping objects to large to fit in RAM?
