fix: namespace and using string for lazy evaluate
parent
ab9610bfe0
commit
1c3685959b
|
@ -12,8 +12,8 @@ module Rating
|
|||
end
|
||||
|
||||
def initialize
|
||||
@rate_model = ::Rating::Rate
|
||||
@rating_model = ::Rating::Rating
|
||||
@rate_model = '::Rating::Rate'
|
||||
@rating_model = '::Rating::Rating'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
module Rating
|
||||
class Rate < ActiveRecord::Base
|
||||
self.table_name = 'rating_rates'
|
||||
self.table_name_prefix = 'rating_'
|
||||
self.table_name = ::Rating.config.rate_model.constantize.table_name
|
||||
|
||||
after_save :update_rating
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
module Rating
|
||||
class Rating < ActiveRecord::Base
|
||||
self.table_name = ::Rating.config.rating_model
|
||||
self.table_name_prefix = 'rating_'
|
||||
self.table_name = ::Rating.config.rating_model.constantize.table_name
|
||||
|
||||
belongs_to :resource, polymorphic: true
|
||||
belongs_to :scopeable, polymorphic: true
|
||||
|
@ -107,7 +108,7 @@ module Rating
|
|||
end
|
||||
|
||||
def rate_table_name
|
||||
@rate_table_name ||= ::Rating.config.rate_model
|
||||
@rate_table_name ||= ::Rating.config.rate_model.constantize.table_name
|
||||
end
|
||||
|
||||
def scope_type_query(scopeable)
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe Rating::Config, 'initialize' do
|
||||
it 'has default models' do
|
||||
expect(subject.rate_model).to eq ::Rating::Rate
|
||||
expect(subject.rating_model).to eq ::Rating::Rating
|
||||
expect(subject.rate_model).to eq '::Rating::Rate'
|
||||
expect(subject.rating_model).to eq '::Rating::Rating'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue