简体   繁体   中英

How to override a rails 3 template within a gem

I have a Rails 3 project where I override some scaffold templates. This is done by placing a new template in lib/templates/erb/scaffold and adding lib to my autoload path in config/application.rb (see Rasilscasts #216).

Now, I'd like to package my work in a gem. (I'm new to gems...)

I cannot figure out how to accomplish this in a gem.

Looking at generators.rb I see there is a configuration for templates dir:

  templates_path.concat config.templates
  templates_path.uniq!

but I'm not sure how to use it.

I don't think I'm supposed to mess with the lib dir from a gem (or even if I can do that).

So my question is, how do I accomplish this from a gem?

Thanks in advance

jeff

Instead of adding lib to your autoload_path you add your gem's lib directory (though I think this should happen automatically). If you provide some code excerpts I can probably give more specific advice, though

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM