diff --git a/config/application.rb b/config/application.rb index 3885751f7..4b25d4278 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,6 +3,7 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' require 'sprockets/railtie' require 'elasticsearch/model' + if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) @@ -83,9 +84,11 @@ module RedmineApp end end + config.wechat_srcs = ['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js'] config.before_initialize do + config.middleware.use ::ResponseIp end config.after_initialize do diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 79641513e..ff3d8de83 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -1,5 +1,15 @@ +#coding=utf-8 +# require 'active_record' +## ruby2.3在这个rails版本的activerecord有bug, 直接用respond_to?(:to_proc)作判断 +#而ruby2.3中hash可以返回 to_proc +if RUBY_VERSION > '2.3' && Rails.version < '3.2.22.3' + Hash.class_eval do + remove_method :to_proc + end +end + module ActiveRecord class Base include Redmine::I18n diff --git a/db/schema.rb b/db/schema.rb index c7d918346..52239eac1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160725091759) do +ActiveRecord::Schema.define(:version => 20160729124833) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,9 +52,24 @@ ActiveRecord::Schema.define(:version => 20160725091759) do add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + create_table "applied_messages", :force => true do |t| + t.integer "user_id" + t.integer "applied_id" + t.string "applied_type" + t.integer "viewed", :default => 0 + t.integer "status", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "name" + t.integer "applied_user_id" + t.integer "role" + t.integer "project_id" + end + create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "role", :default => 0 end create_table "apply_add_schools", :force => true do |t| @@ -577,9 +592,9 @@ ActiveRecord::Schema.define(:version => 20160725091759) do t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 - t.integer "syllabus_id" t.string "invite_code" t.string "qrcode" + t.integer "syllabus_id" end add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true @@ -1106,9 +1121,10 @@ ActiveRecord::Schema.define(:version => 20160725091759) do end create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false + t.integer "member_id", :null => false + t.integer "role_id", :null => false t.integer "inherited_from" + t.integer "is_current", :default => 1 end add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" @@ -1539,6 +1555,8 @@ ActiveRecord::Schema.define(:version => 20160725091759) do t.integer "boards_reply_count", :default => 0 t.integer "visits", :default => 0 t.integer "hot", :default => 0 + t.string "invite_code" + t.string "qrcode" end add_index "projects", ["lft"], :name => "index_projects_on_lft" diff --git a/lib/response_ip.rb b/lib/response_ip.rb new file mode 100644 index 000000000..97c93d222 --- /dev/null +++ b/lib/response_ip.rb @@ -0,0 +1,20 @@ +#coding=utf-8 +# +require 'socket' + +class ResponseIp + def initialize(app) + @app = app + end + + def ip + addr = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address rescue + addr || '' + end + + def call(env) + status, headers, body = @app.call(env) + headers["X-response-ip"] = ip + [status, headers, body] + end +end