0 votes
in Ruby by
Given this Category model with an attribute for "name", what code would fill in the blank so that it sets saved_name to a string that is the category name that existed before the name was changed?

class Category < ActiveRecord::Base

  # has a database column for :name

end

category = Category.first

category.name = 'News'

saved_name = _____

a. category.name_was

b. category.saved(:name)

c. category.changes[:name]

d. category.name_changed?

1 Answer

0 votes
by

Given this Category model with an attribute for "name", what code would fill in the blank so that it sets saved_name to a string that is the category name that existed before the name was changed?

class Category < ActiveRecord::Base

  # has a database column for :name

end

category = Category.first

category.name = 'News'

saved_name = _____

Correct answer is :-  category.changes[:name]

Related questions

0 votes
asked Sep 3, 2022 in Ruby by DavidAnderson
0 votes
asked Sep 2, 2022 in Ruby by DavidAnderson
...