Parse params
This commit is contained in:
parent
6a50234e04
commit
f084987d41
7
main.rb
7
main.rb
|
@ -18,7 +18,12 @@ end
|
||||||
|
|
||||||
get '/examples' do
|
get '/examples' do
|
||||||
$DB_POOL.with do |db_conn|
|
$DB_POOL.with do |db_conn|
|
||||||
ids = params[:ids]
|
ids =
|
||||||
|
case params[:ids]
|
||||||
|
when Array then params[:ids].map { |id| Integer id }
|
||||||
|
when String then params[:ids].split(',').map { |id| Integer id }
|
||||||
|
else raise 'Invalid param "ids"'
|
||||||
|
end
|
||||||
|
|
||||||
examples = db_conn.exec_params(
|
examples = db_conn.exec_params(
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in New Issue