Module: Seymour::Renderable

Extended by:
ActiveSupport::Concern
Defined in:
lib/seymour/renderable.rb

Instance Method Summary collapse

Instance Method Details

#render(controller_name, action_name, env = {}) ⇒ Object

Raises:



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/seymour/renderable.rb', line 15

def render(controller_name, action_name, env = {})
  # TODO define proper server name
    # { "REQUEST_URI" => "", "SERVER_NAME" => 'http://www.example.com' }.merge(env))

  env = Rack::MockRequest.env_for("/",
    { "REQUEST_URI" => "", "SERVER_NAME" => '' }.merge(env))

  controller_class = "#{controller_name}_controller".classify.constantize

  status, headers, response = controller_class.action(action_name.to_sym).call(env)
  raise RenderError.new("#{controller_name}##{action_name}") unless status.to_i == 200
  response.body
end

#render_htmlObject



9
10
11
12
13
# File 'lib/seymour/renderable.rb', line 9

def render_html
  render("seymour/render", "activity", "seymour.activity" => self)
rescue RenderError
  return nil
end