active_element

0.0.13
Light Mode Dark Mode

Options

Tables receive the following keyword arguments:

Keyword Description
collection A collection of objects. Must be iterable, e.g. the result of calling where on an ActiveRecord model. Renders a Collection Table
item A single object. Renders an Item Table. Note that you must use either collection or item but not both.
fields (Required) An array specifying the fields to display in the table. The keys specified in this array can be either hash keys or ActiveRecord attribute names.
model_name Pass model_name if you are not using ActiveRecord objects, e.g. if you are passing a hash or array of hashes, model_name should be provided to provide decorators, translations, CSS classes, etc. This argument should be omitted for ActiveRecord objects (or any object that implements ActiveModel::Naming.
class_name Provide an explicit class name to override the default derived from the received ActiveRecord model class or the model_name parameter.
show A boolean value specifying whether to display a Show button in a collection table. The path for the link is derived from the received ActiveRecord object, e.g. user_path(record)
destroy A boolean value specifying whether to display a Delete button for each record in a collection table or for the single record in an item table. Links to e.g. user_path(record, method: :delete)
edit A boolean value specifying whether to display an Edit button. Links to e.g. edit_user_path(record)
new A boolean value specifying whether to display a “Create new …” button above a collection table. Links to e.g. new_user_path
style Specify a CSS string to be inserted into the <table> tag.
row_class Specify a class to be inserted into each <tr> tag in a collection table. Can be a String or a Proc. A Proc will receive the record as an argument, e.g.: row_class: ->(record) { record.deleted_at.present? 'text-danger' : 'text-primary' }
group Group rows in a collection by a given attribute, e.g.: group: :country_code.
paginate Enable or disable pagination for collection tables. Defaults to true.

Documentation generated by rspec-documentation