Created
January 26, 2013 16:35
-
-
Save thiagofm/4643155 to your computer and use it in GitHub Desktop.
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
| allowed_params = [:name, :stats, :xpto] | |
| params = { | |
| name: 'Blabla', | |
| stats: '123' | |
| } | |
| def update(allowed_params, params) | |
| # validate if params are allowed | |
| params.each do |param| | |
| raise 'Bad Request' unless allowed_params.include? params | |
| end | |
| # proceed to update the data | |
| end | |
| p 'First try' | |
| update(allowed_params, params) | |
| p 'Second try' | |
| update(allowed_params, params.merge!({illegal: '123'})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment