空数据库时部分数据没有,添加非空判断

This commit is contained in:
z9hang 2014-09-09 11:58:35 +08:00
parent 63470476a5
commit c9f6259587
3 changed files with 7 additions and 9 deletions

View File

@ -791,7 +791,7 @@ class UsersController < ApplicationController
# 必填自己的工作单位,其实就是学校
def auth_user_extension
if @user == User.current && @user.user_extensions.school.nil?
if @user == User.current && (@user.user_extensions.nil? || @user.user_extensions.school.nil?)
flash[:error] = l(:error_complete_occupation)
redirect_to my_account_path
end

View File

@ -64,7 +64,7 @@ class WelcomeController < ApplicationController
@course_page = FirstPage.where("page_type = 'course'").first
if params[:school_id]
@school_id = params[:school_id]
elsif User.current.logged? && User.current.user_extensions.school
elsif User.current.logged? && User.current.user_extensions.try(:school)
@school_id = User.current.user_extensions.school.try(:id)
end
@logoLink ||= logolink()

View File

@ -437,9 +437,9 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
t.string "web_title"
t.string "title"
t.text "description"
t.string "page_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "page_type"
t.integer "sort_type"
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
@ -976,10 +976,11 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
t.string "url"
t.string "title"
t.integer "share_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "project_id"
t.integer "user_id"
t.string "description"
end
create_table "softapplications", :force => true do |t|
@ -1085,8 +1086,8 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
t.integer "zip_code"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "identity"
t.string "technical_title"
t.integer "identity"
t.string "student_id"
t.string "teacher_realname"
t.string "student_realname"
@ -1144,9 +1145,6 @@ ActiveRecord::Schema.define(:version => 20140826072838) do
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
t.integer "file"
t.integer "issue"
end
create_table "user_statuses", :force => true do |t|