method

match?

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: ActiveModel::Name
match? public

Equivalent to String#match?. Match the class name against the given regexp. Returns true if there is a match, otherwise false.

class BlogPost
  extend ActiveModel::Naming
end

BlogPost.model_name.match?(/Post/) # => true
BlogPost.model_name.match?(/\d/) # => false
Show source
Register or log in to add new notes.