Update Database in Ruby on Rails version 7.11

48 Views Asked by At

Hello community I am new to ruby on rails, I have a problem with updating the database, when I try to update a record, all records are updated

this is my article_controller this is my router

I was reviewing the documentation and I saw that I do it similarly, I have searched for information on the internet and I can't find a solution

I want to update only one record by passing the id

1

There are 1 best solutions below

0
arieljuod On BEST ANSWER

You want to do:

@article.update(article_params)

when you do Article.update you are in fact updating all

EDIT: I'd also recommend following the conventions, using resources :articles is preferred https://guides.rubyonrails.org/routing.html#resources-on-the-web