Override Rails scaffold generator
For those who are lazy, here is a quick command to copy the default railties erb templates to the correct location in Rails:
mkdir -p lib/templates/erb/scaffold && \
cp $(bundle info railties --path)/lib/rails/generators/erb/scaffold/templates/* lib/templates/erb/scaffold
Well after a couple months I've found the solution. Instead of creating a new generator as the Rails documentation states, I override the default generator but in my projects lib
folder.
The original scaffold_generator.rb
is located at ~/.rvm/gems/ruby-2.1.0/gems/railties-4.2.4/lib/rails/generators/erb/scaffold
. To add the new file (_info.html.erb
) we will add it to the available_views
method.
def available_views
%w(index edit show new _form _info)
end
Hope it helps someone.