The active record has an update method that finds by identifiers and updates attributes. But this will cause two sql queries.
update(id, attributes)
eg,
Post.update(params[:id], {:title => 'Hello world'})
If you do not want the checks to be performed, you can use
Post.update_all({:title => 'hello1'}, {:id => params[:id]})
This will make only one sql request
user946611
source share