Recently I thought of setting up custom view scaffold for our project. In order to setup the default views like index, edit, show, new & _form are easy, just need to put our custom html in lib/template/erb/scaffold directory.
Here is an example of edit.html.erb custom HTML.
Note that I have used <%% & <%%= which will prevent the evaluation of expression.
The class_name, plural_table_name, singular_table_name are the methods provided by rails to create scaffold. Since I used <%= around class_name, the expression will be evaluated while generating the scaffold.
After some googling, as usual a stackoverflow answer showed a way generate custom view files. In that answer, the author actually defined a new template engine. But It doesn’t support generating index.js. So I tweaked some and made it possible.
Now configure new Custom template engine,
In Rails 3
Done, Now rails g scaffold <name> command will generate index, edit, show, new, _form, _search_form, _table & index.js.