Last active
October 27, 2016 02:16
-
-
Save smd686s/6320643 to your computer and use it in GitHub Desktop.
Use Strong Parameters in a Grape API without Rails
This file contains 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
require 'rack/test' | |
require 'action_controller/metal/strong_parameters' | |
# https://github.com/rails/rails/blob/master/actionpack/test/controller/parameters/parameters_require_test.rb | |
module Application | |
class API < Grape::API | |
helpers do | |
def item_params | |
ActionController::Parameters.new(params).require(:item).permit(:attribute) | |
end | |
end | |
desc "Create an item." | |
post :items do | |
Item.new item_params | |
end | |
end | |
end |
This file contains 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
gem "actionpack", "~> 4.0.0" |
if I'm on a pure Rack, why do I ever need actionpack? https://github.com/ruby-grape/grape/blob/master/grape.gemspec#L15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
our solution without need to include 'action_controller/metal/strong_parameters'
https://gist.github.com/BGuimberteau/4da1ab54e576121edde5