Want to let everyone know that I am almost done hacking the generator.
However I hit into an issue which due to my short age with ruby I
don't understand how to implement properly- the route_resources
command does not allow me to do namespace. I want to add 2 methods,
one to add namespace, the other one to do route_resources within a
specified namespace, how should I add it to the Rails generator create
command? (I bet its something like extend/include an addon module? but
somehow I am a bit confused on this one still) it would be great if
someone could contribute this piece of code.
Most important thing: you may get the code from google code:
Simply use SVN to checkout and put it in your .rails home to play
around it. Or you may also create a new rails project and then throw
it inside lib/generators.
Guys I made an update- now it will also generate appropriate routes
inside routes.rb (but the indentation need some tuning, which I will
fix it later) Basically I tried to do 2-3 level namespaces nesting and
they all work correctly now.
Known issues:
1. Imperfect indentation in routes.rb- will be fixed very soon
2. Ugly code: the extended route_resources_in_namespace is really some
quick hack thus it has quite a bit duplications
3. Destroy does not remove namespace route, you have to do it yourself
4. Multiple scaffold elements does not reuse namespace code block,
thats really difficult to fix as it has to follow the entire hierarchy
to make sure the namespace is suitable to be used. Anyway I think its
minor issue as all you really need to fix are just inside routes.rb.
Please let me know if you have any questions, and if you found it
useful, please reply the post so I know you are using it