提交 da3891c8 编写于 作者: A Aaron Patterson

make sure cached table name is a string. fixes #12582

上级 6e2b734f
......@@ -20,7 +20,7 @@ def klass; @rhs_class_name.constantize; end
def self.build(lhs_class, name, options)
if options[:join_table]
KnownTable.new options[:join_table]
KnownTable.new options[:join_table].to_s
else
class_name = options.fetch(:class_name) {
name.to_s.camelize.singularize
......
......@@ -570,6 +570,13 @@ def test_consider_type
assert !developer.special_projects.include?(other_project)
end
def test_symbol_join_table
developer = Developer.first
sp = developer.sym_special_projects.create("name" => "omg")
developer.reload
assert_includes developer.sym_special_projects, sp
end
def test_update_attributes_after_push_without_duplicate_join_table_rows
developer = Developer.new("name" => "Kano")
project = SpecialProject.create("name" => "Special Project")
......
......@@ -36,6 +36,10 @@ def find_least_recent
end
has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'
has_and_belongs_to_many :sym_special_projects,
:join_table => :developers_projects,
:association_foreign_key => 'project_id',
:class_name => 'SpecialProject'
has_many :audit_logs
has_many :contracts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册