Skip to content

Commit

Permalink
Use except to avoid mass assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
jonallured committed Mar 6, 2024
1 parent d9d67b1 commit da9763a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/api/using_grape/artworks_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ArtworksEndpoint < Grape::API
end

post do
artwork = Artwork.new(params)
artwork = Artwork.new(params.except(:featured))
if artwork.save
artwork
else
Expand All @@ -23,7 +23,7 @@ class ArtworksEndpoint < Grape::API

put ":id" do
artwork = Artwork.find(params[:id])
if artwork.update(params)
if artwork.update(params.except(:featured))
artwork
else
errors = {errors: artwork.errors.full_messages.to_sentence}
Expand Down

0 comments on commit da9763a

Please sign in to comment.