Skip to content
No description, website, or topics provided.
Ruby CSS JavaScript CoffeeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib
log
public
vendor/assets
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

Problem: You've got an endpoint that's accepting post requests that

contain the key action or controller and need access to the post values.

I thought about this for a bit and googled around with out quick solution. In the end I decided to solve this problem by creating a simple middleware.

# lib/params_fixer.rb

class ParamsFixer
  def initialize(app)
    @app = app
  end

  def call(env)
    request = Rack::Request.new(env)
    if request.params['action']
      request.update_param('beer_db_action', request.params['action'])
    end
    status, headers, resp = @app.call(env)
    [status, headers, resp]
  end
end
# config/application.rb
  config.autoload_paths += Dir["#{config.root}/lib/**/"]

  config.middleware.use "ParamsFixer"
You can’t perform that action at this time.