SORU
14 ŞUBAT 2011, PAZARTESİ


Raylar: around_* geri

http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html, belgeleri okudum ama around_* geri before_* after_* ilgili tetiklendiğinde anlamıyorum.

Herhangi bir yardım çok takdir.

Teşekkürler.

CEVAP
14 ŞUBAT 2011, PAZARTESİ


Around_* geri before_* ve after_* eylemler içinde ve etrafında eylem denir. Örneğin:

class User
  def before_save
    puts 'before save'
  end

  def after_save
    puts 'after_save'
  end

  def around_save
    puts 'in around save'
    yield
    puts 'out around save'
  end
end

User.save
  before save
  in around save
  out around save
  after_save
=> true

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • gamingbits

    gamingbits

    2 Mayıs 2006
  • NewsyTech

    NewsyTech

    2 AĞUSTOS 2010
  • TecNoob

    TecNoob

    15 AĞUSTOS 2013