I’m trying to customize my scaffold generator, and I would like to have a new partial for the view in the same directory, in particular _item to be called both inside index and show. I can get all the templates but I’m not able to generate this file through
rails g scaffold foo name:string
I tried to put _item.erb in /lib/templates/erb/scaffold/ (together with the other files) but it is ignored- Does anybody have a clue?
I use ruby on rails 3, but please let me know if the solution is valid for rails 2 as well.
I also use simple_form (thus I already have the _form partial), but I think the solution should be valid even without it.
Just found it.
It is hardcoded. You can change it:
https://github.com/rails/rails/blob/master/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
In my index template I did like this:
Then, just created a rake task that reads that comment and create the new files.
Ugly but effective.