instance method source_path

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

source_path(relative_source)

Return the full path from the source root for the given path. Example for source_root = ‘/source’:

source_path('some/path.rb') == '/source/some/path.rb'

The given path may include a colon ‘:’ character to indicate that the file belongs to another generator. This notation allows any generator to borrow files from another. Example:

source_path('model:fixture.yml') = '/model/source/path/fixture.yml'

Parameters

relative_source req
Source
# File railties/lib/rails_generator/base.rb, line 134
      def source_path(relative_source)
        # Check whether we're referring to another generator's file.
        name, path = relative_source.split(':', 2)

        # If not, return the full path to our source file.
        if path.nil?
          File.join(source_root, name)

        # Otherwise, ask our referral for the file.
        else
          # FIXME: this is broken, though almost always true.  Others'
          # source_root are not necessarily the templates dir.
          File.join(self.class.lookup(name).path, 'templates', path)
        end
      end

Defined in railties/lib/rails_generator/base.rb line 134 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generator::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close