1
我注意到RailsAdmin有object_label方法,但目前還不清楚如何使用它:如何創建一個自定義的object_label而不需要向域類添加新的方法?
config.model Entity do
object_label do
# ???
end
end
我注意到RailsAdmin有object_label方法,但目前還不清楚如何使用它:如何創建一個自定義的object_label而不需要向域類添加新的方法?
config.model Entity do
object_label do
# ???
end
end
RailsAdmin.config do |config|
config.model Team do
object_label_method do
:custom_label_method
end
end
def custom_label_method
"Team #{self.name}"
end
end
提煉如果你只是想從模型中使用的屬性,你可以通過它作爲被調用的方法...像:name
將返回object.name
作爲標籤。