The Lucid
Photo of The Lucid

UX Designer, CSS Wizard, Ruby on Rails Developer.

Rails Edge: View file extention functionality has changed

It seems that on edge revision 6502 and later, the way that view file extensions has changed considerably.
I couldn’t work out why my tests were breaking when doing an xhr request to a new action which had a respond_to block setup for both html and js. It was returning the html instead of the rjs??
It turns out (after tearing my hair out for over three hours) that “Changeset 6499”: changes things in such a way that the normal new.rjs naming will not get picked up on an xhr request, you now need to add the request format to the extension before the template type i.e. new.js.rjs
This seemed a little odd at first but I am guessing it means you could have a new.js.erb file which is pretty cool as you could achieve the same as “Dan Webb’s MinusR plugin”:
What does seem a little odd is that a new.rjs will get picked up if you don’t give a respond_to at-all (I don’t know if this is a “feature” or a bug).
I’m am hoping that this may save someone some time.