New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The :source option for has_many => through should accept String values. #14668

Merged
merged 1 commit into from Apr 9, 2014

Conversation

Projects
None yet
3 participants
@laurocaetano
Copy link
Contributor

laurocaetano commented Apr 9, 2014

With the changes introduced by 16b70fd it was expecting the value to be a Symbol, while it could also be a String value.

The solution was call to_sym on the given :source.

Fixes #14651

This PR should only be backported to 4-1-stable

@rafaelfranca

View changes

activerecord/lib/active_record/reflection.rb Outdated
@@ -481,7 +481,7 @@ class ThroughReflection < AssociationReflection #:nodoc:

def initialize(macro, name, scope, options, active_record)
super
@source_reflection_name = options[:source]
@source_reflection_name = options[:source] ? options[:source].to_sym : options[:source]

This comment has been minimized.

@rafaelfranca

rafaelfranca Apr 9, 2014

Member

can we do this inside source_reflection_name method?

The `source` option for `has_many => through` should accept String
values.

With the changes introduced by 16b70fd
it was expecting the value to be a Symbol, while it could be also a
String value.
@laurocaetano

This comment has been minimized.

Copy link
Contributor

laurocaetano commented Apr 9, 2014

@rafaelfranca updated, what do you think?

@tenderlove

This comment has been minimized.

Copy link
Member

tenderlove commented Apr 9, 2014

I'd prefer all the caches internally use strings. What breaks when they use a string?

tenderlove added a commit that referenced this pull request Apr 9, 2014

Merge pull request #14668 from laurocaetano/source_option_with_string…
…_value

The :source option for has_many => through should accept String values.

@tenderlove tenderlove merged commit 1368311 into rails:master Apr 9, 2014

tenderlove added a commit that referenced this pull request Apr 9, 2014

Merge pull request #14668 from laurocaetano/source_option_with_string…
…_value

The :source option for has_many => through should accept String values.

laurocaetano added a commit to laurocaetano/rails that referenced this pull request Apr 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment