How to: Create a Singular Resource - TrestleAdmin/trestle GitHub Wiki
In case only a particular instance of a certain Model is to be shown in an admin view, you can use an instance
block to identify the instance which is to be displayed.
For example if /admin/profile
should link to the current_user
instance of the User
model do the following (observe that everything is the same except instance
instead of collection
is used):
Trestle.resource(:profile, singular: true, model: User) do
instance { current_user } # To have a singleton model, use: User.first_or_create
menu do
item :profile, icon: "fa fa-star"
end
form do |user|
text_field :name
text_field :email
end
end