Skip to content

Helpers are not accessible from inside params block #1805

Open
@atshakil

Description

@atshakil

Helpers can be accessed from before and request blocks (e.g. get, post). But, params block can not access helpers the same way.

In the following snippet, params block throws a NoMethodError for process_query.

route_param :cat_id do
  before do
    @cat = Cat.find process_id(params[:cat_id])
  end

  desc "An endpoint"
  params do
    optional :query, type: String, coerce_with: ->(query){process_query query}
  end
  get :kittens do
    process_id(params[:cat_id])
  end
end

Is there a way to access helpers from inside the params block?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions