Comment on page
These methods are already defined on your All Futures class. 90% of the time, these defaults are great. If you have complex needs, you can redefine them with your own logic.
Responsible for converting the model instance into a valid DOM
id. Can be passed to a StimulusReflex Morph and used as a CableReady
selector. Converts namespaced classes to double-dashes.
[self.class.name.underscore.dasherize.gsub("/", "--"), id].join("-")
If you attempt to sort two objects of the same class, Ruby will call the
to_keymethod and use the Array it returns to sort. By default, the
to_keyArray contains the
id. Since All Futures models frequently have a UUIDv4
id, this isn't a useful sorting criteria.
You can specify one or more attributes - or other values - to sort by instead.
[name, age, id]
Returns a String representing the model's key suitable for use in URLs, or
false. The key is usually the
id, but this can be overwritten to provide vanity URL slugs.
Active Record model instances can be passed to Rails'
rendermethod, and if ActionPack can locate a partial in the correct location based on that model, it will render that partial.
to_partial_pathis responsible for this magic.
All Futures models can also be passed to
render. If you have a
drafts/draftand ActionPack will look for
app/views/drafts/_draft.html.erb. If this isn't where the partial for your model is located, define your own:
ActionPack will now attempt to render
readonly?to see if this model instance has been marked as
readonly, which prevents all
Want to ensure that no changes are written to Redis for this model class, ever?