Skip to content

Maybe bug in BelongsToManyAssociation custom_default_value #92

Closed
@lasseebert

Description

Hi!

I can confirm that my previous issue is indeed solved in my case 🎉

I ran into another thing now trying to implement belongs-to-many relations.

The private custom_default_value method fails with undefined method 'default' for nil on this line:

def column_default_value
  owner.class.columns_hash[source_attr].default
end

When I debug, it turns out that source_attr is a symbol but columns_hash has string keys.

I'm not sure if the fix just is to to_s the symbol or if it should be changed deeper in the code. (Just changing to use to_s locally makes my code work).

The line in my code that triggers this, is when I try to assign to the association with something like my_model.tags = [my_tag], but I guess the line in question could be reached in many way.

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions