Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created July 10, 2018 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/60fe7ca610ad3ddf53f6378471f7087b to your computer and use it in GitHub Desktop.
Save chelseatroy/60fe7ca610ad3ddf53f6378471f7087b to your computer and use it in GitHub Desktop.
Combining Query Parameters and Request Bodies
class MembersController < ApplicationController
...
def index
@members = member_params.any? ? Member.where(member_params) : Member.all
json_options = params.fetch(:json_options, {})
render json: @members.as_json(HashWithIndifferentAccess.new(json_options.permit!))
end
def member_params
params.permit(:member_id, :employer_id, :plan_id)
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment