Skip to content

Instantly share code, notes, and snippets.

@sushant12
Created June 3, 2017 06:10
Show Gist options
  • Save sushant12/0cef2724bcaf30949e7be3bd3580d79e to your computer and use it in GitHub Desktop.
Save sushant12/0cef2724bcaf30949e7be3bd3580d79e to your computer and use it in GitHub Desktop.
module Todo
class BaseController
attr_reader :env
def initialize(env)
@env = env
end
def params
Rack::Request.new(env).params
end
def render(view)
Tilt::ERBTemplate.new("app/views/layouts/application.html.erb").render {
Tilt::ERBTemplate.new("app/views/#{view}.html.erb").render(self)
}
end
def redirect_to path
body = %Q(Redirecting to <a href="#{path}">#{path}</a>)
header = { "Location" => path }
[body, 301, header]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment