My first contribution : a couple of patches toward dynamic scaffold_resource

Posted by Tim Connor Mon, 16 Oct 2006 16:17:00 GMT

I just submitted my first two patches to Ruby on Rails. I was thinking that I wanted something a certain way, and the best way to get that is contribute. I submitted these two “tiny” patches:

[PATCH] add options[:url] to form() in active_record_helper.rb – partially allows for RESTful call

[PATCH] add options[:method] to form() in active_record_helper.rb – partially allows for RESTful call

as they truly are tiny and might get applied. And of course, I submitted the tests, so my patches didn’t get tossed out immeditately.

I have to say trying to get Rails to pass its tests is a pain, and from the look of their ticket system, some of those might not be meant to pass yet (TDD). Anyways, I gave up on some of the minor tests that might not work on my system (Win32), and just made sure I did not break anything else, in making my changes. One I did that, it was actually pretty easy.

Then since the end goal I am aiming at is significantly larger, I submitted the following email to the core mailing list, instead of just jumping in and stepping on toes.

So I’ve RESTified a couple controllers, now, using the latest stuff in
Edge and they don’t feel very-DRY. I realize that after they get more
complicated they will need to be able to be stand-alone, but they are
currently pretty wet. I considered working on an abstract REST
controller, but then realized that dynamic scaffolding was almost all I
needed. I just want to be able to not have to repeat myself until the
controller diverges from the norm.

Now perhaps an abstract controller might be able to be figured out in
such a way to allow for better TDD, but I think basically a copy of the
current generated tests for scaffold_resource could just be dropped in
test for those who want to do TDD, and the scaffolding could use
updating if everything is supposed to move towards REST/CRUD.

I submitted a couple tiny patches to active_record_helper.rb form() to
add options[:url] and options[:method] so that the ARH form could at
least be called in the current REST style (since the scaffolding uses
that form(), which was hard-coded to an old-style url :action =>), but
wanted to ask here before proceeding further.

Am I completely off base here? If I want a dynamic scaffold_resource
:model should I proceed and submit the patch? Should I just update the
current scaffolding to use the new REST style, or make it
scaffold_resource? What are the odds of this sort of thing getting
applied? More likely given the push to REST, and since this would add
another minor nudge? Should I make any other tiny patches needed to
core, and then just make the rest a plug-in?

Tim

So nothing has been accepted yet, but my first patches are submitted at least. Yay!