Skip to content

Instantly share code, notes, and snippets.

@gordielachance
Last active March 5, 2020 08:40
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 gordielachance/1238ebdb452e5f6fbd8cb2600bb7a851 to your computer and use it in GitHub Desktop.
Save gordielachance/1238ebdb452e5f6fbd8cb2600bb7a851 to your computer and use it in GitHub Desktop.
Hi, i've got problems validating parameters sent to my API route.
puts "PARAMS"
puts params.to_json
=begin
{
"url":"http://www.last.fm/user/grosbouff/loved",
"options":{
"selectors":{
"playlist":{
"tracks":{
"path":"table.chartlist tbody tr"
}
},
"track":{
"artist":{
"path":"td.chartlist-name .chartlist-ellipsis-wrap .chartlist-artists a"
},
"title":{
"path":"td.chartlist-name .chartlist-ellipsis-wrap > a"
},"image":{
"path":"img.cover-art","attr":"src"
}
}
}
}
}
=end
puts "REQUIRE"
puts params.require(:url)
#returns
#http://www.last.fm/user/grosbouff/love
puts "PERMIT"
puts params.permit(:options)
#returns
#Unpermitted parameters: :url, :options
#{}
#why is parmas.permit firing an error ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment