Edit a database record through the Rails console

  • Find the record

    You can use find or where to get the record open up the rails console run the command Meme.all spot the record you want to update, get the ID of that record.(Lets say ID is 5)

    @meme = Meme.find(5) or @meme = Meme.where(:title => "Balloon frihgtens cat")

  • Update the record

    @meme.update(:title => "Balloon frightens cat")


Step 1. Find the record.

Step 2. Edit the record.

Assuming title is unique, the following should work:

> m = Meme.where(:title => 'Balloon frihgtens cat').first
> m.title = 'Balloon frightens cat'
> m.save

Read up http://guides.rubyonrails.org/active_record_querying.html to learn more about using active record.