Need to update a single record’s attribute? This will allow you to update a single attribute and save your record. If you use this method, you will also bypass any validation…beware, attributes can be updated even if the object is invalid.
# find the first Condo
# update the flagged column with the params
current_condo = Condo.find(:first)
current_condo.update_attribute(:flagged, params[:submission][:flagged])
# find the the condo by permalink
# set the condo.name and condo.zipcode
# save
condo = Condo.find_by_permalink("114-pike-street-condos")
condo.name = "114 Pike Street Condos"
condo.zipcode = "98105"
condo.save!
# update the flagged column with the params
current_condo = Condo.find(:first)
current_condo.update_attribute(:flagged, params[:submission][:flagged])
# find the the condo by permalink
# set the condo.name and condo.zipcode
# save
condo = Condo.find_by_permalink("114-pike-street-condos")
condo.name = "114 Pike Street Condos"
condo.zipcode = "98105"
condo.save!
Tags: activerecord, rails, update
Thanks, found this useful.
cool,.tnx..^^
cool,.tnx..^^