What's an appropriate way to override the view of a gem?

I thought it would be overkill to unpack the entire gem into my application. Is there a way to just override a single view it provides?

This gem is spree_easy_contact which allows you to easily add a contact form to your Spree application. I just want to tamper with one of the views to say something alternative.


If the gem is namespaced, then you can namespace your view in your local application. For example, if the gem is namespaced to best_gem_ever, then your app structure would look like this:

app
- assets
- controllers
- helpers
- mailers
- models
- views
- - best_gem_ever
- - - wonderful_controller
- - - - index.html.erb

At my job, we purposefully use this technique to allow clients to overwrite front-end views while still pulling administrative views from the gem. It works really well.

One caveat, if you create any asset files that you store in your local assets folder, then for some reason the asset pipeline doesn't pick them up. They have to be explicitly added to your config.assets.precompile list.

Hope that helps!