Skip to content

Commit da9763a

Browse files
committed
Use except to avoid mass assignment
1 parent d9d67b1 commit da9763a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/api/using_grape/artworks_endpoint.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ArtworksEndpoint < Grape::API
1212
end
1313

1414
post do
15-
artwork = Artwork.new(params)
15+
artwork = Artwork.new(params.except(:featured))
1616
if artwork.save
1717
artwork
1818
else
@@ -23,7 +23,7 @@ class ArtworksEndpoint < Grape::API
2323

2424
put ":id" do
2525
artwork = Artwork.find(params[:id])
26-
if artwork.update(params)
26+
if artwork.update(params.except(:featured))
2727
artwork
2828
else
2929
errors = {errors: artwork.errors.full_messages.to_sentence}

0 commit comments

Comments
 (0)