Skip to content

Commit

Permalink
Merge dbd0ed1 into f592d68
Browse files Browse the repository at this point in the history
  • Loading branch information
dexion committed Feb 20, 2019
2 parents f592d68 + dbd0ed1 commit 2a486d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rails_admin/config/actions/dashboard.rb
Expand Up @@ -31,7 +31,8 @@ class Dashboard < RailsAdmin::Config::Actions::Base
@max = current_count > @max ? current_count : @max
@count[t.model.name] = current_count
next unless t.properties.detect { |c| c.name == :created_at }
@most_recent_created[t.model.name] = t.model.last.try(:created_at)
sort_field = t.properties.detect { |c| c.name == t.config.dashboard_sort_by} ? t.config.dashboard_sort_by : nil
@most_recent_created[t.model.name] = t.model.order(sort_field).last.try(:created_at)
end
end
render @action.template_name, status: @status_code || :ok
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/model.rb
Expand Up @@ -97,6 +97,10 @@ def pluralize(count)
nil
end

register_instance_option :dashboard_sort_by do
nil
end

# Act as a proxy for the base section configuration that actually
# store the configurations.
def method_missing(m, *args, &block)
Expand Down

0 comments on commit 2a486d6

Please sign in to comment.