Renders the template present at template_path. If use_full_path is set to true, it’s relative to the view_paths array, otherwise it’s absolute. The hash in local_assigns is made available as local variables.
Source Code
# File action_view/base.rb, line 278 def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc: if defined?(ActionMailer) && defined?(ActionMailer::Base) && controller.is_a?(ActionMailer::Base) && !template_path.include?("/") raise ActionViewError, "Due to changes in ActionMailer, you need to provide the mailer_name along with the template name.\n\nrender \"user_mailer/signup\"\nrender :file => \"user_mailer/signup\"\n\nIf you are rendering a subtemplate, you must now use controller-like partial syntax:\n\nrender :partial => 'signup' # no mailer_name necessary\n" end @first_render ||= template_path template_path_without_extension, template_extension = path_and_extension(template_path) if use_full_path if template_extension template_file_name = full_template_path(template_path_without_extension, template_extension) else template_extension = pick_template_extension(template_path).to_s unless template_extension raise ActionViewError, "No template found for #{template_path} in #{view_paths.inspect}" end template_file_name = full_template_path(template_path, template_extension) template_extension = template_extension.gsub(/^.+\./, '') # strip off any formats end else template_file_name = template_path end template_source = nil # Don't read the source until we know that it is required if template_file_name.blank? raise ActionViewError, "Couldn't find template file for #{template_path} in #{view_paths.inspect}" end begin render_template(template_extension, template_source, template_file_name, local_assigns) rescue Exception => e if TemplateError === e e.sub_template_of(template_file_name) raise e else raise TemplateError.new(find_base_path_for("#{template_path_without_extension}.#{template_extension}") || view_paths.first, template_file_name, @assigns, template_source, e) end end end
<code/>and<pre/>for code samples.