diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d3e635c9c..1930e1c32 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -8,6 +8,8 @@ def index @results = Model.where(field.matches("%#{@query}%")) @results += Model.tagged_with(@query) @results.uniq! + else + @recent = Model.order(created_at: :desc).limit(20) end end diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 41215d692..ef47630b5 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -25,3 +25,19 @@ Search for more on Yeggi <% end %> +<% if @recent %> +
+
+

Recently-added Models

+ + <% @recent.each do |model| %> + + + + + + <% end %> +
<%= link_to model.name, library_model_path(model.library, model) %><%= link_to model.library.name, model.library %><%= time_ago_in_words(model.created_at) %> ago
+
+
+<% end %>