Skip to content

Instantly share code, notes, and snippets.

@masqita
Created July 9, 2010 13:18
Show Gist options
  • Select an option

  • Save masqita/469445 to your computer and use it in GitHub Desktop.

Select an option

Save masqita/469445 to your computer and use it in GitHub Desktop.

Revisions

  1. masqita renamed this gist Jul 9, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. masqita created this gist Jul 9, 2010.
    21 changes: 21 additions & 0 deletions Example Cookie Middleware
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # In /lib/foo_bar_middleware.rb

    class FooBarMiddleware

    def initialize(app, options={})
    @app = app
    # options will be {:foo => :bar} if you look lower down, you can use this in other methods etc
    @options = options
    end

    def call(env)
    request = ::Rack::Request.new(env)
    @cookies = request.cookies
    @app.call(env)
    end


    end

    # In environment.rb:
    config.middleware.insert_before(ActionController::Session::CookieStore, 'FooBarMiddleware', {:foo => :bar})