Update_attribute on a specific record

Newbie alert! :slight_smile:

Guys, I am trying to update a record on the console (Heroku)
I have an object called Photo
Photos have a tittle,… how do I address an specific photo via it’s
Id if I want to
update the tittle description etc?

Any help will be great.

On Feb 10, 2012, at 5:30 AM, abenego wrote:

Newbie alert! :slight_smile:

Guys, I am trying to update a record on the console (Heroku)
I have an object called Photo
Photos have a tittle,… how do I address an specific photo via it’s
Id if I want to
update the tittle description etc?

If you know the ID, then you can do this:

photo = Photo.find 123
photo.title = ‘A greater title than before’
photo.save

Walter

Yep, or:
Photo.find(123).update_attribute(:title => “New great title”)

Regards

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs