overriding gem controllers and views

I can override any gem’s controllers and views by creating them in my app?

Yes, you can

Model

project_folder/lib/templates/active_record/model/model.rb

Controller

project_folder/lib/templates/rails/scaffold_controller/controller.rb

Views

project_folder/lib/templates/erb/scaffold/

All the original file can be founded inside railties folder (bundle show railties)

You can also add views editing scaffold_generator.rb

Cheers

Mauro

Sorry I’ve seen now the word ‘gems’
My instructions are to make override of scaffold generator.

Mauro

Right. It's even easier for a gem. Just put your templates in the same relative place within your normal rails views or controllers, properly named, and they will "shadow" the version within the gem. In most things in Rails, "nearest wins". Gems insert their code into the Rails lookup path *after* the core application code, not before. So if you add code to the core, it will be found before the gem's code is, and Rails will stop looking at that point.

I just dealt with this last night, when I overrode the Thredded gem to make the breadcrumbs work the way I needed them to. All I had to do was add this folder:

  app/views/thredded/shared

and add the _breadcrumbs.html.erb file to that folder, and I had complete control over that one file (without needing to shadow every other part of the gem).

Walter