Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

修改 tasks.rb, 判断是否继承自 ActiveRecord::Base, 应该用 klass < ActiveRecord::Base #33

Merged
merged 1 commit into from

2 participants

@tumayun

修改 tasks.rb, 判断是否继承自 ActiveRecord::Base, 应该用 klass < ActiveRecord::Base
还有 ENV['BUNDLE_GEMFILE'] 指定错误

@tumayun tumayun commented on the diff
lib/redis/search/tasks.rb
@@ -11,12 +11,12 @@
puts ""
Redis::Search.indexed_models.each do |klass|
print "[#{klass.to_s}]"
- if klass.superclass.to_s == "ActiveRecord::Base"
+ if klass < ActiveRecord::Base
@tumayun
tumayun added a note
class Address < ActiveRecord::Base
end

class HomeAddress < Address
end

HomeAddress.superclass.to_s # "Address"
HomeAddress.superclass.to_s == 'ActiveRecord::Base' # false
HomeAddress < ActiveRecord::Base # true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tumayun tumayun commented on the diff
spec/spec_helper.rb
@@ -1,6 +1,6 @@
require 'rubygems'
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', File.dirname(__FILE__))
@tumayun
tumayun added a note
File.expand_path('../Gemfile', __FILE__) # /home/tumayun/workspace/code/redis-search/spec/Gemfile
File.expand_path('../Gemfile', File.dirname(__FILE__)) # /home/tumayun/workspace/code/redis-search/Gemfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@huacnlee huacnlee merged commit f58fb3c into huacnlee:master
@tumayun tumayun referenced this pull request
Open

不支持单表继承 #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +5 −5 lib/redis/search/tasks.rb
  2. +1 −1  spec/spec_helper.rb
View
10 lib/redis/search/tasks.rb
@@ -11,12 +11,12 @@
puts ""
Redis::Search.indexed_models.each do |klass|
print "[#{klass.to_s}]"
- if klass.superclass.to_s == "ActiveRecord::Base"
+ if klass < ActiveRecord::Base
@tumayun
tumayun added a note
class Address < ActiveRecord::Base
end

class HomeAddress < Address
end

HomeAddress.superclass.to_s # "Address"
HomeAddress.superclass.to_s == 'ActiveRecord::Base' # false
HomeAddress < ActiveRecord::Base # true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
klass.find_in_batches(:batch_size => 1000) do |items|
items.each do |item|
item.redis_search_index_create
- item = nil
- count += 1
+ item = nil
+ count += 1
print "."
end
end
@@ -24,8 +24,8 @@
klass.all.each_slice(1000) do |items|
items.each do |item|
item.redis_search_index_create
- item = nil
- count += 1
+ item = nil
+ count += 1
print "."
end
end
View
2  spec/spec_helper.rb
@@ -1,6 +1,6 @@
require 'rubygems'
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', File.dirname(__FILE__))
@tumayun
tumayun added a note
File.expand_path('../Gemfile', __FILE__) # /home/tumayun/workspace/code/redis-search/spec/Gemfile
File.expand_path('../Gemfile', File.dirname(__FILE__)) # /home/tumayun/workspace/code/redis-search/Gemfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
Something went wrong with that request. Please try again.