Created
July 10, 2018 03:39
-
-
Save chelseatroy/60fe7ca610ad3ddf53f6378471f7087b to your computer and use it in GitHub Desktop.
Combining Query Parameters and Request Bodies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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