Space Vatican

Ramblings of a curious coder

:locals and String Keys

If you ever do this

  render :some_partial, :locals => {'foo' => 'bar'}

don’t. String keys in :locals have been deprecated for a while and are no longer supported in edge (and thus in the not too distant 2.1), so go ahead and change them now and you’ll save yourself some grief when you migrate to 2.1.

When things break it’s always nice when they break in an obvious way, so in this case foo not being defined at all in the partial makes it immediately obvious that something has change from :locals. You check the api docs, maybe google around a bit and see that string keys aren’t accepted any more. If you do use a string key like this the foo will still be defined it will just be nil. You probably won’t suspect an api change and spend some time hunting up and down as to why the variable you’re using in :locals is nil (at least that’s what I did – hopefully you won’t have to do the same now!).