hashrocket / decent_exposure

A helper for creating declarative interfaces in controllers
MIT License
1.81k stars 107 forks source link

Override build params for HEAD requests #194

Closed ildarkayumov closed 3 years ago

ildarkayumov commented 4 years ago

Hi everyone.

class ThingsController < ApplicationController
  expose :thing

  def new
    thing.author = 'John Doe'
  end

  private

  def thing_params
    params.require(:thing).permit(:foo, :bar)
  end
end

When exposed object is called in controller action and somebody sends HEAD request instead of GET it raises error:

ActionController::ParameterMissing (param is missing or the value is empty: thing):

because DecentExposure::Behavior#build_params returns empty hash only for GET requests.

It doesn't look like a big problem but anyway it's a bit annoying. Can we change this logic?

Thx

mattpolito commented 3 years ago

Thank you, sorry for the late merge.

dillonhafer commented 3 years ago

This is awesome!

ildarkayumov commented 3 years ago

👍