views:

29

answers:

1

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

+1  A: 

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

bjeanes
ok I will (tomorrow), but (1) how does a gem modify the autoload path and (2) the gem's lib dir could be anywhere? Is there a constant I should make use of?
theschmitzer
actually I think it IS in my autoload path from my gemspec's require_paths command. That I have verified. But that does not appear to be how templates are loaded.
theschmitzer
This is because autoload/require paths are for ruby files, not templates. There should be another variable (like view_paths or something) that you use instead.
bjeanes