Vicente G. Reyes
Vicente Garcia-Reyes

Vicente Garcia-Reyes

Using the update_attribute() API using the rails console

Vicente G. Reyes's photo
Vicente G. Reyes
Β·Aug 3, 2020Β·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

I had a task at work to add data from the rails console after generating migrations and was puzzled on how to do it. After spending some time on the problem, I asked for help and this is what I got:

object.description = "Lorem Ipsum"

The problem was, it returned false which I had a hint that it didn't work.

I checked the frontend and it didn't show the data I entered and ran reload on the rails console again but it still didn't update the data.

I knew I had to check the docs and figure out how to do it.

I found this answer on SO which helped me with my problem.

object.update_attribute(:book_description, "Lorem Ipsum")

This updated the data on the frontend which was the goal of the task.

Share this


Code snippets/words may be mine unless otherwise stated on each article.