instance method dom_class

Ruby on Rails 8.0.4

Since v4.0.13

Available in: v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

dom_class(record_or_class, prefix = nil)

The DOM class convention is to use the singular form of an object or class.

dom_class(post)   # => "post"
dom_class(Person) # => "person"

If you need to address multiple instances of the same class in the same view, you can prefix the dom_class:

dom_class(post, :edit)   # => "edit_post"
dom_class(Person, :edit) # => "edit_person"

Parameters

record_or_class req
prefix opt = nil
Source
# File actionview/lib/action_view/record_identifier.rb, line 78
    def dom_class(record_or_class, prefix = nil)
      singular = model_name_from_record_or_class(record_or_class).param_key
      prefix ? "#{prefix}#{JOIN}#{singular}" : singular
    end

Defined in actionview/lib/action_view/record_identifier.rb line 78 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::RecordIdentifier

Type at least 2 characters to search.

↑↓ navigate · open · esc close