From 2dd249a10573d4fb22960edc4bb08521b22b921c Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 4 Jul 2014 10:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8F=91=E5=B8=96=E4=B8=8D?= =?UTF-8?q?=E5=A1=AB=E4=B8=BB=E9=A2=98=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E5=8F=91=E5=B8=96=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=8F=AF=E6=88=90=E5=8A=9F=E5=8F=91=E5=B8=83?= =?UTF-8?q?bug=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=BB=E9=A1=B5=E8=B4=B4?= =?UTF-8?q?=E5=90=A7=E5=8A=A8=E6=80=81=E9=87=8C=E5=9B=9E=E5=B8=96=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E9=A2=9C=E8=89=B2=E3=80=81=E4=BF=AE=E6=94=B9=E6=98=B5?= =?UTF-8?q?=E7=A7=B0=E5=AD=97=E7=AC=A6=E4=B8=BA=E4=B8=8D=E8=B6=85=E8=BF=87?= =?UTF-8?q?25=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 15 +++++++++++---- app/models/memo.rb | 4 ++-- app/models/user.rb | 2 +- public/stylesheets/welcome.css | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index b4de06fb6..62f860a96 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -51,7 +51,10 @@ class MemosController < ApplicationController @memo_new = @memo.dup @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 - @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) + unless @memo.new_record? + @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) + end + page = params[:page] if params[:r] && page.nil? @@ -68,10 +71,14 @@ class MemosController < ApplicationController limit(@reply_pages.per_page). offset(@reply_pages.offset). all + if @memo.new_record? + format.html { redirect_to back_url, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + else + format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + # format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + format.json { render json: @memo.errors, status: :unprocessable_entity } + end - format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } - # format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } - format.json { render json: @memo.errors, status: :unprocessable_entity } end end end diff --git a/app/models/memo.rb b/app/models/memo.rb index 1e857a223..feb10dec9 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -3,9 +3,9 @@ class Memo < ActiveRecord::Base belongs_to :forum belongs_to :author, :class_name => "User", :foreign_key => 'author_id' - validates_presence_of :author_id, :forum_id, :subject + validates_presence_of :author_id, :forum_id, :subject,:content # 若是主题帖,则内容可以是空 - validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? } + #validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? } validates_length_of :subject, maximum: 50 validates_length_of :content, maximum: 3072 validate :cannot_reply_to_locked_topic, :on => :create diff --git a/app/models/user.rb b/app/models/user.rb index 6138f9b56..257681cb5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -164,7 +164,7 @@ class User < Principal # Prevents unauthorized assignments attr_protected :login, :admin, :password, :password_confirmation, :hashed_password - LOGIN_LENGTH_LIMIT = 60 + LOGIN_LENGTH_LIMIT = 25 MAIL_LENGTH_LIMIT = 60 validates_presence_of :login, :firstname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } diff --git a/public/stylesheets/welcome.css b/public/stylesheets/welcome.css index 4636ca5af..c6bdd1ab5 100644 --- a/public/stylesheets/welcome.css +++ b/public/stylesheets/welcome.css @@ -449,7 +449,7 @@ a.attachments_list_color { font-size: 9pt; } .memo_activity span a{ - color: gray; + /*color: gray;*/ } /*帖子的最后回复人*/ .memo_activity .memo_last_person{