Module: ActiveRecordView::RenderArv

Included in:
Controller, Helper
Defined in:
lib/active_record_view/render_arv.rb

Instance Method Summary collapse

Instance Method Details

#render(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/active_record_view/render_arv.rb', line 3

def render(*args, &block)
  options = args.first
  if options.is_a?(Hash) and options[:arv]
    arv = options.delete(:arv)
    render_arv(arv, options)
  else
    super
  end
end

#render_arv(arv, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/active_record_view/render_arv.rb', line 13

def render_arv(arv, options = {})
  path, arv_name = partial_pieces(arv.to_s)
  root  = Pathname(RAILS_ROOT).cleanpath.to_s + "/"
  file  = "app/views/%s/%s.arv" % [path, arv_name]
  rhtml = arv_erb_code(File.read(root + file), arv_name, options)
  ActiveRecord::Base.logger.debug "Rendering %s" % file.inspect
  render :inline=>rhtml
end