jeudi 12 décembre 2019

how respond_to? method works in rails

I came across code snippet something like this.

attr_accessor :category, :search

  def run
    if respond_to?((category&.downcase).to_s, true)
      send(category.downcase)
    else
      send(:tag)
    end
  end

But I am not sure what does belongs_to? does in this scenerio. Any help would be greatly appreciated. Thanks !

Aucun commentaire:

Enregistrer un commentaire