diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 35baab3..63acc9f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,8 +2,16 @@
+
-
+
+
+
+
+
+
+
+
@@ -21,7 +29,7 @@
-
+
@@ -31,7 +39,38 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -46,21 +85,23 @@
-
-
-
-
+
+
+
+
+
+
@@ -128,6 +169,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -217,6 +290,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -420,35 +533,35 @@
-
+
-
+
-
-
+
+
-
+
+
+
+
-
-
-
@@ -467,13 +580,6 @@
-
-
- file://$PROJECT_DIR$/app/controllers/micro_posts_controller.rb
- 21
-
-
-
@@ -487,13 +593,6 @@
-
-
-
-
-
-
-
@@ -581,21 +680,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -617,48 +701,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -693,14 +735,6 @@
-
-
-
-
-
-
-
-
@@ -750,14 +784,6 @@
-
-
-
-
-
-
-
-
@@ -766,14 +792,6 @@
-
-
-
-
-
-
-
-
@@ -793,14 +811,6 @@
-
-
-
-
-
-
-
-
@@ -809,14 +819,6 @@
-
-
-
-
-
-
-
-
@@ -825,14 +827,6 @@
-
-
-
-
-
-
-
-
@@ -841,5 +835,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 79f2914..d0ca988 100644
--- a/Gemfile
+++ b/Gemfile
@@ -26,7 +26,6 @@ gem 'jbuilder', '~> 2.5'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# for windows
-gem 'bcrypt-ruby', '~> 3.0.0', :require => "bcrypt"
# will_paginate
gem 'will_paginate', '~> 3.1.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index d5f7370..eb295f9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -41,7 +41,6 @@ GEM
arel (7.1.4)
bcrypt (3.1.11)
bcrypt (3.1.11-x64-mingw32)
- bcrypt-ruby (3.0.1)
builder (3.2.2)
byebug (9.0.6)
coffee-rails (4.2.1)
@@ -168,7 +167,6 @@ PLATFORMS
DEPENDENCIES
bcrypt (~> 3.1.7)
- bcrypt-ruby (~> 3.0.0)
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
diff --git a/app/controllers/chat_controller.rb b/app/controllers/chat_controller.rb
index e4286ad..f08f138 100644
--- a/app/controllers/chat_controller.rb
+++ b/app/controllers/chat_controller.rb
@@ -31,9 +31,9 @@ class ChatController < ApplicationController
create_time: save_time, readed: false)
if msg_db.save
- render json: {username: username, userpic: userpic, content: msg, time: save_time}
+ render json: {username: username, userpic: userpic, content: msg, time: get_strftime(save_time)}
else
- render json: {username: username, userpic: userpic, content: "error", time: save_time}
+ render json: {username: username, userpic: userpic, content: "error", time: get_strftime(save_time)}
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 28a9a8a..7fed9aa 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,8 +1,8 @@
module ApplicationHelper
- def utc_time_to_local utctime
+ def get_strftime intime
# 将数据库中的UTC时间转换为本地时间
- return utctime.localtime.strftime(format='%F %T')
+ return intime.localtime.strftime(format='%F %T')
end
end
diff --git a/app/helpers/chat_helper.rb b/app/helpers/chat_helper.rb
index aea59f3..ee84c9b 100644
--- a/app/helpers/chat_helper.rb
+++ b/app/helpers/chat_helper.rb
@@ -43,12 +43,12 @@ module ChatHelper
messages.each do |message|
if message.send_user == user.id
x = {issend: true, name: user.name, userpic: user.picurl,
- content: message.content, time: utc_time_to_local(message.create_time)}
+ content: message.content, time: get_strftime(message.create_time)}
else
message.readed = true
message.save
x = {issend: false, name: chat_with.name, userpic: chat_with.picurl,
- content: message.content, time: utc_time_to_local(message.create_time)}
+ content: message.content, time: get_strftime(message.create_time)}
end
results << x
end
diff --git a/app/helpers/main_helper.rb b/app/helpers/main_helper.rb
index f1adda2..5d36b0d 100644
--- a/app/helpers/main_helper.rb
+++ b/app/helpers/main_helper.rb
@@ -21,7 +21,7 @@ module MainHelper
else
x["type"] = "新鲜事"
end
- x["time"] = utc_time_to_local(micro_post.post_time)
+ x["time"] = get_strftime(micro_post.post_time)
x["pics"] = micro_post.pic.split(',') if micro_post.pic
x["peo_num"] = micro_post.engage_people
micro_posts_array << x
@@ -50,7 +50,7 @@ module MainHelper
else
x["type"] = "新鲜事"
end
- x["time"] = utc_time_to_local(micro_post.post_time)
+ x["time"] = get_strftime(micro_post.post_time)
x["pics"] = micro_post.pic.split(',') if micro_post.pic
x["peo_num"] = micro_post.engage_people
micro_posts_array << x
diff --git a/app/helpers/micro_posts_helper.rb b/app/helpers/micro_posts_helper.rb
index b76acc7..53ed12d 100644
--- a/app/helpers/micro_posts_helper.rb
+++ b/app/helpers/micro_posts_helper.rb
@@ -21,7 +21,7 @@ module MicroPostsHelper
else
x["type"] = "新鲜事"
end
- x["time"] = utc_time_to_local(micro_post.post_time)
+ x["time"] = get_strftime(micro_post.post_time)
x["pics"] = micro_post.pic.split(',') if micro_post.pic
x["peo_num"] = micro_post.engage_people
micro_posts_array << x
@@ -35,7 +35,8 @@ module MicroPostsHelper
FileUtils.mkdir_p(@@micro_posts_dir)
end
ext = File.extname(pic.original_filename)
- save_name = Digest::MD5::hexdigest(pic.original_filename) + ext
+ timestamp = Time.now.to_s
+ save_name = Digest::MD5::hexdigest(pic.original_filename + timestamp) + ext
File.open(File.join(@@micro_posts_dir, save_name), 'wb') { |f| f.write(pic.read) }
return save_name
end
diff --git a/app/views/main/main.html.erb b/app/views/main/main.html.erb
index ac0e728..49131fd 100644
--- a/app/views/main/main.html.erb
+++ b/app/views/main/main.html.erb
@@ -5,7 +5,7 @@
<%= render 'layouts/nav' %>
-
+
<% @micro_posts_array.each do |micro_post| %>
diff --git a/config/application.rb b/config/application.rb
index 086705c..94d17ee 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -11,5 +11,6 @@ module GuorenPro
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
+ config.time_zone = 'Beijing'
end
end
diff --git a/db/development.sqlite3 b/db/development.sqlite3
index fcbad81..522c854 100644
Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ