MinusMOR Released!

Okay then you bunch of wusses. Here’s your goddamn liberal, namby-pamby, let’s sit on the fence version of MinusR that doesn’t override anything and provides your JavaScript with embedded Ruby templates as the .ejs extension so it works alongside the normal .rjs templates. Live and let live. Let’s all hold hands and be nice to each other….

Damn you, you hippies!

It’s in my SVN repos but you can still get at MinusR if you are feeling hardcore. I must admit that the whole thing does smell better than the original version. It turns out that changing the default behaviour of respond_to for different types has got easier since last time I looked as well. Go core team! It was also easier to test which normally indicates a sweeter smell of code. In the end it required more monkey patching that MinusR to get it to work correctly. It turns out that .rjs templates trigger a few hardcoded special cases to template handling and to get .ejs files to act the same required patching these hardcoded bits which is a shame. It looked like it was going to be nice and clean.

Now I’ve gone out of the way to make this version especially for you people you MUST use it. I’ll be checking…

20 Comments (Closed)

Awesome. I didn’t think DHH was a hippie though ;-)

PratikPratik at 23.11.06 / 19PM

I have to say, this is the way things should be done in the first place. Altough, overriding the .rjs behaviour would make using MinusR impossible for existing projects using the default RJS. So, MinusMOR is the way to go :) I’ll definitely use it from now on.

Rodrigo KochenburgerRodrigo Kochenburger at 23.11.06 / 23PM

Just fixed a few issues in it and I’ve need to monkey patch part of the Rails core which was annoying. A bit of nasty hardcoding slipped in it seemed. Not quite as pretty as I’d have hoped but not bad.

Pratik: He’s hiding all that hippiness underneath a thin layer of ‘opinionated developer’....I’m on to him though :)

DanDan at 24.11.06 / 00AM

Hum. Just out of interest, what is MinusMOR and where can I find more info on it?

Joel MossJoel Moss at 24.11.06 / 01AM

Joel: Sorry, I should have linked back to the previous post. All will become clear once you read about MinusR.

DanDan at 24.11.06 / 01AM

This is great, can’t wait to try it out.

Thanks binq

binqbinq at 24.11.06 / 04AM

Dan, thanks for creating MinusR+MinusMOR. My favourite plugin(s) of the month!

Dr NicDr Nic at 24.11.06 / 21PM

Great stuff. Please submit a patch to core that’ll make it easier to create your own template extensions that feel and smell just like the real thing.

DHHDHH at 25.11.06 / 22PM

The tight coupling of client and server generated by sending JavaScript as a server response is the good thing that RJS emphasized. People argue and I agree that this tight coupling is bad in some cases and that raw data in XML or JSON should be returned. For most sites the tight coupling is fine and enables short development time.

I think that the RJS implementation of wrapping JavaScript in Ruby was not a good idea. The individual lines of RJS are about as complicated as the generated lines of JavaScript.

A web programmer that doesn’t know JavaScript is going to have a rough time anyway so why hide JavaScript at all.

Thanks for this plugin especially in the ejs form.

Peter MichauxPeter Michaux at 26.11.06 / 06AM

Thanks man, awesome work. I hope you can submit a patch to Rails to get a cleaner implementation. I’d hate to install this and then have some core change break it on an update

crayzcrayz at 26.11.06 / 19PM

Looks great! However, I’m having some issues with exempt_from_layout being undefined on ActionController::Base. Any ideas? Prolly something silly and I’m just stiill suffering from Turkey-induced woosiness… Sigh.

napnap at 26.11.06 / 22PM

Do MinusR / MinusMOR require edge rails or something? When I installed MinusR it gave me a load time error about alias_method_chain not existing, and now MinusMOR is barfing on undefined method for “exempt_from_layout”.

oliver nicholasoliver nicholas at 27.11.06 / 18PM

Oliver: Yes, alias_method_chain has turned up since the last set of gems and it sounds like exempt from layout has too but I didn’t know this previously. Since 1.2 is about to come out I’m not too worried though.

DanDan at 27.11.06 / 20PM

I’m using 1.2 RC 1 on my dev box and still seem to be lacking exempt_from_layout…

napnap at 27.11.06 / 20PM

That’s weird. If you look at the source taged as 1.2 RC1 in the Rails subversion repository it’s definitely there. Maybe you’re running from earlier gems or you have an old version frozen to vendor.

If you /script/console and do Rails::VERSION::STRING do you get ‘1.2.0’?

DanDan at 27.11.06 / 20PM

Well, version string reports as 1.1.6 but this is expected behavior until 1.2 is actually released. In the meantime, edge rails will report 1.2 but anyone using 1.2 RC 1 should still see ‘1.1.6’ as their version string. The updated gem will install as ‘rails-’ but the 5618 (SVN rev #) isn’t used by the version string.

fwiw, I’m not frozen to an older version or anything either. I too thought it was kinda weird. Will probably do a bit more spelunking tonight.

napnap at 27.11.06 / 22PM

Nap: Yeah, sorry, you’re right. The RC does have the method though. Look here. Please lete me know if you find out what’s going on. Cheers!

DanDan at 27.11.06 / 23PM

Seems that GemRails still points to 1.1.6 instead of No idea why. In any case, this is obviously fixed by just freezing the project on edge rails with the right tag.

rake rails:freeze:edge TAG=rel_1-2-0_RC1

Thanks for the help Dan; the plugin rocks.

napnap at 28.11.06 / 00AM

Yes… Good idea.. if trains were invented today.. we would not replace the highways with railroad tracks… DUH!!!

BobBob at 02.12.06 / 16PM


Very good plugin! I’ve become an overnight advocate of jQuery, so this is perfect for me.

You do have a bug, though! This was kind of a tricky one, but I found it in the source code. This bug doesn’t make itself known until you use Internet Explorer 7. It has to do with the Content-Type you set. Check line 26 in minus_mor.rb:

@action_view.controller.headers[‘Content-Type’] = ‘text/javascript; charset=utf=8’

Notice the “utf=8”? That needs to be “utf-8”. When it’s “utf=8”, Internet Explorer can’t parse the headers properly, or something, and as a result, you get a nasty error instead of the Javascript you expected.

Good work, and take care!! Sean

Sean GilbertsonSean Gilbertson at 09.01.07 / 17PM

About This Article