1.

What Is The Use Of Super In Ruby Rails?

Answer»

The function super is used to invoke the ORIGINAL method, SEARCHING of the method body starts in the super class of the OBJECT that was found to contain the original method. The following example DEPICTS the same.

def url=(address)
super (address.blank? || address.starts_with?('http')) ? address : http://#{address}
END

The function super is used to invoke the original method, searching of the method body starts in the super class of the object that was found to contain the original method. The following example depicts the same.

def url=(address)
super (address.blank? || address.starts_with?('http')) ? address : http://#{address}
end



Discussion

No Comment Found