Answer by Mayinx for How do I check if an argument is an instance of model or...
In case you want to make sure that the object in question is not only any class but a model class - i.e. a (direct or indirect) descendant of ActiveRecord::Base:my_object.is_a?(Class) &&...
View ArticleAnswer by Max Williams for How do I check if an argument is an instance of...
if myobject.is_a?(Foo) #it's an instance of fooelse #it's something elseendorif myobject.is_a?(Class) #it's a classelse #it's notend
View ArticleHow do I check if an argument is an instance of model or the class in Rails?
I have a helper method which generates "crud" links for a resource.Right now it only handles edit and destroy. But I want to refactor it so that it would create a new link if passed a model class...
View Article
More Pages to Explore .....