The Book model have
- name column
- author column
- ad column (I want to add)
I would like to add 'Mr' to the name column and add them to the ad column. For that, I wanted to write a script with migration file, but it did not work. What should I do? Thanks
class AddAdToBooks < ActiveRecord::Migration
def change
add_column :books, :ad, :string
Book.all.each do |book|
book.ad = 'Mr.' + name
book.save
end
end
end
BookstoBook