[Erector-devel] rails generators (the second)
kristian
m.kristian at web.de
Mon Apr 6 00:59:43 EDT 2009
hello,
I once had this topic again but it was turned down in favour of the erect tool.
but I need to get to it again. time passed and the way I use erector
is beyond what the default generator and erect are doing.
the best is to have a look at my personal sandbox
http://github.com/mkristian/kristians_rails_plugins/tree/e41ee0ef959c5837ee3d257c41d4ee4a0ab1233a/erector_widgets
why I think an erector generator is better than the combination rails
default generator + erect:
* rerun the generator allows to identify modified files, you can have
look at the diff and decide whether you want to overwrite them or not.
with
rails default generator + erect you do not get that feature
* erector is more elegant then just replacing erb files with erector widgets
the above generator uses datamapper instead of activerecord that is
why things like the error messages are a bit strange. anyways what I
do here is to offer two base widgets for displaying data models. for
each restful resource I have 4 view files: new.rb, show.rb, edit.rb
and index.rb. the first three reuse the MyModelWidget and the index.rb
uses MyModelsWidget (the list of model entities). with this all four
files are very small and on top you can use the MyModel(s)Widgets at
other places where needed. so basically using a composite pattern to
setup the views.
so in my opinion this would help to show the potential which lies in
erector. since the above is my personal sandbox is carries some extras
which is not needed for a public, but if you guys change your opinion
about erector generators I can provide them. if you do not like my
approach that is also OK for me since I am using erector all over the
place and I am about to migrate even two more small projects to use
erector (most probably using my generators and regenerate some code
with it)
with regards Kristian
More information about the Erector-devel
mailing list