-
-
Notifications
You must be signed in to change notification settings - Fork 0
Repository
Mattia Roccoberton edited this page May 2, 2023
·
1 revision
ActiveRecord component to prepare the queries for resources' actions.
Sample:
# Change the repository globally:
repository: TinyAdmin::Plugins::ActiveRecordRepository
Or locally in a resource section:
sections:
- slug: posts
name: Posts
type: resource
model: Post
repository: MyRepository
Then define your repository:
class MyRepository < TinyAdmin::Plugins::ActiveRecordRepository
# override specific methods
def collection
model.some_nice_scope
end
def show_title(record)
"MyModel #{record.name}"
end
end
If you prefer you can create your own Repository, I would suggest to inherit from TinyAdmin::Plugins::BaseRepository
in that case.
Take a look at the sample_features_app in the extra folder for a complete example of a custom repository.