From b6c814f8fafcce8d201430ea6972af18409d19ed Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 2 Dec 2015 18:35:15 +0800 Subject: [PATCH] sort and date fixed --- app/models/patent.rb | 4 +++- app/views/admin/patents/_form.html.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/patent.rb b/app/models/patent.rb index cec7330..c13a01f 100644 --- a/app/models/patent.rb +++ b/app/models/patent.rb @@ -29,6 +29,8 @@ class Patent before_validation :add_http + scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc") } + def get_plugin_data(fields_to_show) plugin_datas = [] fields_to_show.each do |field| @@ -55,7 +57,7 @@ class Patent } end - plugin_datas = datas.where(:is_hidden=>false).order_by(:year=>'desc').collect do |p| + plugin_datas = datas.sort_for_frontend.collect do |p| pd_data = [] fields_to_show.collect do |t| diff --git a/app/views/admin/patents/_form.html.erb b/app/views/admin/patents/_form.html.erb index decf243..2c4273f 100644 --- a/app/views/admin/patents/_form.html.erb +++ b/app/views/admin/patents/_form.html.erb @@ -180,7 +180,7 @@
- <%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM" %> + <%= f.datetime_picker :publish_date, :no_label => true, :format=>"yyyy/MM", :value => @patent.publish_date, :new_record => @patent.new_record? %>