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