Back to code
Finally I’ve found some more time to code. Actually, talking with Bryan we established a mini timeline to bring up a nice feature for the admin view, the ability to change settings from the web and save them as YAML code for future reuse, but before that I found out I did something really wrong WRT the admin geenaration (plus I found some problems related to reloading settings).
The problem is that I was inadvertently reusing the builtin part/admin instead of the one I generated so my testing was useless.
I’m now recapping the work, and in the process trying to clean up the scaffolded views.
To simplify them I’ll try to add table_for and to remove the strange needed for proper path setup.
<?r base="#@base/%base%" ?>
to allow proper setting of paths to actions.
@base is the base path, i.e. for AdminController it is / and for FooController mounted over admin it is /admin. Ok.
base is gsubbed at “compile” time with the real controller name/path. Ok.
Lastly, base is overriding a Nitro::Controller#base method wich allows access to the above instance variable.
All in all, not very “obvious” code.
So I ended up sending a patch to the ML that adds a Controller#path method to access Controller.mount_path, the code could then be refactored nicely, because what @base/%base% do is basically recreate mount_path.
Talking about refactoring, I was thinking that we could make use of facets’ __DIR__ which allows access to the directory of the current file. It seem there are quite a bit of places where this is approach used in all Nitro/Og, so consolidating them with an already available method seem A Good Thing.
Leave a Reply (use Markdown Syntax)