mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:42:16 +08:00
Some Rails4 updates
This commit is contained in:
parent
112b9f9c2a
commit
b19f631b3a
4
Gemfile
4
Gemfile
|
@ -49,6 +49,8 @@ else
|
|||
gem 'sprockets', git: 'https://github.com/SamSaffron/sprockets.git', branch: 'rails-compat'
|
||||
gem 'redis-rails'
|
||||
gem 'seed-fu'
|
||||
gem 'activerecord-postgres-hstore'
|
||||
gem 'active_attr'
|
||||
end
|
||||
|
||||
gem 'redis'
|
||||
|
@ -71,8 +73,6 @@ gem 'rails_multisite', path: 'vendor/gems/rails_multisite'
|
|||
gem 'simple_handlebars_rails', path: 'vendor/gems/simple_handlebars_rails'
|
||||
|
||||
gem 'redcarpet', require: false
|
||||
gem 'activerecord-postgres-hstore'
|
||||
gem 'active_attr' # until we get ActiveModel::Model with Rails 4
|
||||
gem 'airbrake', '3.1.2', require: false # errbit is broken with 3.1.3 for now
|
||||
gem 'clockwork', require: false
|
||||
gem 'eventmachine'
|
||||
|
|
|
@ -248,7 +248,7 @@ GEM
|
|||
minitest (4.7.3)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.7.6)
|
||||
multi_json (1.7.7)
|
||||
multipart-post (1.2.0)
|
||||
mustache (0.99.4)
|
||||
net-scp (1.1.0)
|
||||
|
|
|
@ -125,9 +125,6 @@ GEM
|
|||
rack-test (~> 0.6.2)
|
||||
actionpack-action_caching (1.0.0)
|
||||
actionpack (>= 4.0.0.beta, < 5.0)
|
||||
active_attr (0.8.2)
|
||||
activemodel (>= 3.0.2, < 4.1)
|
||||
activesupport (>= 3.0.2, < 4.1)
|
||||
activemodel (4.0.0)
|
||||
activesupport (= 4.0.0)
|
||||
builder (~> 3.1.0)
|
||||
|
@ -137,10 +134,6 @@ GEM
|
|||
activesupport (= 4.0.0)
|
||||
arel (~> 4.0.0)
|
||||
activerecord-deprecated_finders (1.0.3)
|
||||
activerecord-postgres-hstore (0.7.6)
|
||||
activerecord (>= 3.1)
|
||||
pg-hstore (>= 1.1.5)
|
||||
rake
|
||||
activesupport (4.0.0)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
minitest (~> 4.2)
|
||||
|
@ -316,7 +309,6 @@ GEM
|
|||
redis
|
||||
ruby-openid
|
||||
pg (0.15.1)
|
||||
pg-hstore (1.1.7)
|
||||
polyglot (0.3.3)
|
||||
progress (2.4.0)
|
||||
protected_attributes (1.0.3)
|
||||
|
@ -478,9 +470,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
actionpack-action_caching
|
||||
active_attr
|
||||
active_model_serializers!
|
||||
activerecord-postgres-hstore
|
||||
airbrake (= 3.1.2)
|
||||
annotate!
|
||||
barber
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
class DiscourseVersionCheck
|
||||
|
||||
# include ActiveModel::Model <-- If we were using Rails 4, we could use this instead of active_attr
|
||||
include ActiveAttr::Attributes
|
||||
include ActiveAttr::MassAssignment
|
||||
include ActiveModel::Serialization
|
||||
if rails4?
|
||||
include ActiveModel::Model
|
||||
else
|
||||
include ActiveAttr::Attributes
|
||||
include ActiveAttr::MassAssignment
|
||||
include ActiveModel::Serialization
|
||||
end
|
||||
|
||||
attr_accessor :latest_version, :critical_updates, :installed_version, :installed_sha, :missing_versions_count, :updated_at
|
||||
|
||||
|
|
|
@ -51,9 +51,7 @@ class Topic < ActiveRecord::Base
|
|||
self.title = TextCleaner.clean_title(TextSentinel.title_sentinel(title).text) if errors[:title].empty?
|
||||
end
|
||||
|
||||
if rails4?
|
||||
store_accessor :meta_data
|
||||
else
|
||||
unless rails4?
|
||||
serialize :meta_data, ActiveRecord::Coders::Hstore
|
||||
end
|
||||
|
||||
|
|
|
@ -2,12 +2,22 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
observe :notification
|
||||
|
||||
def after_commit(notification)
|
||||
if notification.send(:transaction_include_action?, :create)
|
||||
notification_type = Notification.types[notification.notification_type]
|
||||
if rails4?
|
||||
if notification.send(:transaction_include_any_action?, [:create])
|
||||
notification_type = Notification.types[notification.notification_type]
|
||||
|
||||
# Delegate to email_user_{{NOTIFICATION_TYPE}} if exists
|
||||
email_method = :"email_user_#{notification_type.to_s}"
|
||||
send(email_method, notification) if respond_to?(email_method)
|
||||
# Delegate to email_user_{{NOTIFICATION_TYPE}} if exists
|
||||
email_method = :"email_user_#{notification_type.to_s}"
|
||||
send(email_method, notification) if respond_to?(email_method)
|
||||
end
|
||||
else
|
||||
if notification.send(:transaction_include_action?, :create)
|
||||
notification_type = Notification.types[notification.notification_type]
|
||||
|
||||
# Delegate to email_user_{{NOTIFICATION_TYPE}} if exists
|
||||
email_method = :"email_user_#{notification_type.to_s}"
|
||||
send(email_method, notification) if respond_to?(email_method)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,12 +33,22 @@ else
|
|||
# Outside of test mode, use after_commit
|
||||
class DiscourseObserver < ActiveRecord::Observer
|
||||
def after_commit(model)
|
||||
if model.send(:transaction_include_action?, :create)
|
||||
after_create_delegator(model)
|
||||
end
|
||||
if rails4?
|
||||
if model.send(:transaction_include_any_action?, [:create])
|
||||
after_create_delegator(model)
|
||||
end
|
||||
|
||||
if model.send(:transaction_include_action?, :destroy)
|
||||
after_destroy_delegator(model)
|
||||
if model.send(:transaction_include_any_action?, [:destroy])
|
||||
after_destroy_delegator(model)
|
||||
end
|
||||
else
|
||||
if model.send(:transaction_include_action?, :create)
|
||||
after_create_delegator(model)
|
||||
end
|
||||
|
||||
if model.send(:transaction_include_action?, :destroy)
|
||||
after_destroy_delegator(model)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user