jeudi 31 octobre 2019

Print Object attributes after creation in rails

I am new to rails and I want to jut print in the console the name of the lastly created record of Document. For this I am using in the model file, after? create callback.

Anyway I can not get the name displayed in the console after I run a procedure of creation. How can this be done to be able to display the name of the lastly created record of type Document?

 class Document < ApplicationRecord
  belongs_to :storage

  after_create :my_function

  def my_function
    puts Document.name
  end
 end

Aucun commentaire:

Enregistrer un commentaire