Created
June 3, 2017 06:10
-
-
Save sushant12/0cef2724bcaf30949e7be3bd3580d79e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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