From 45076cd31f13ceb7539f3250e183563ef8ee3188 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 2 Dec 2015 18:26:24 +0800 Subject: [PATCH] sorting and dates fixed --- app/models/book.rb | 2 ++ app/views/admin/books/_form.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/book.rb b/app/models/book.rb index e7c987f..6ce36cf 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -39,6 +39,8 @@ class Book before_validation :add_http + scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc") } + def create_link title = [] # title << self.member_profile.name if self.member_profile.present? diff --git a/app/views/admin/books/_form.html.erb b/app/views/admin/books/_form.html.erb index 19adeb5..347bbb7 100644 --- a/app/views/admin/books/_form.html.erb +++ b/app/views/admin/books/_form.html.erb @@ -223,7 +223,7 @@
- <%= f.datetime_picker :publish_date, :no_label => true,:format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %> + <%= f.datetime_picker :publish_date, :no_label => true,:format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD", :value => @book.publish_date, :new_record => @book.new_record? %>
@@ -231,7 +231,7 @@
- <%= f.datetime_picker :publication_date, :no_label => true,:format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %> + <%= f.datetime_picker :publication_date, :no_label => true,:format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD", :value => @book.publication_date, :new_record => @book.new_record? %>