Ruby on Rails Thursday, August 29, 2013

In the rails documentation, it states that:

In Rails 3.0 and above, generators don't just look in the source root for templates, they also search for templates in other paths. And one of them is lib/templates. Since we want to customize Rails::Generators::HelperGenerator, we can do that by simply making a template copy inside lib/templates/rails/helper with the name helper.rb.

I'm trying to dig through the rails source code to see where this lookup occurs.  I've gotten this far.

In railties/lib/rails/generators/rails/helper/helper_generator.rb, the code
template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb")

seems to be calling the super class' method (railties/lib/rails/generators/named_base.rb):
      # Defines the template that would be used for the migration file.
      # The arguments include the source template file, the migration filename etc.
      no_tasks do
        def template(source, *args, &block)
          inside_template do
            super
          end
        end
      end

This in turn inherits from name_base inherits from base, but the method "template" doesnt seem to appear in that class.

Where can I find the code that does this lookup?


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2328b9a7-c5f2-4146-b375-99fd66fd73bb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment