use rails 4.0 strong parameter in non rails application

1k Views Asked by At

I use active-record 4.0 in a grape api application, but as strong parameter only works in rails controller, how do I permit params in a grape api class

1

There are 1 best solutions below

2
On

There seems to be a way to use the strong parameters outside the controller

raw_parameters = { :email => "[email protected]", :name => "John", :admin => true }
parameters = ActionController::Parameters.new(raw_parameters)
user = User.create(parameters.permit(:name, :email))

For more info check the repository documentation on github https://github.com/rails/strong_parameters

Regards