I am using administrate for the first time in a Ruby On Rails project. I have read the user guide, generated some custom views and made some changes. But it feels like my problem is very common and that creating custom views and make changes to it, is not the best way to go.
I have a model called Battle
and Battle has_many competitors
.
When I watch the show
view for a Battle
it starts with a list of all competitors and the first column in this table is a reference to the battle (belongs_to).
It says Battle#1
and I want to change this to the name
of this Battle instead of Battle#1
.
Also in the form where I can add a new battle, the drop-down to select the (belongs_to) battle shows Battle#1
of course it should mention the name of this battle here.
I just can't figure out the easy way to change this. Is there a config file where I can tell this to the application.
Hope someone can help me in the right direction...
In the app/dashboards folder administrate creates a config file for each model currently present in the application.
Just before the last
end
statement it shows some code that is commented out. In the case of a model named Battle it will look like thisYou can un-comment it and change it as you like. In this case the model has a column called name that should be used. The code would we:
Now everywhere across all pages of in the admin dashboards that the administrate gem creates this resource is displayed with the return value of this method.