Quantcast
Channel: How do I check if an argument is an instance of model or the class in Rails? - Stack Overflow
Browsing latest articles
Browse All 3 View Live

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 Article



Answer 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 Article

How 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
Browsing latest articles
Browse All 3 View Live




Latest Images