Skip to content
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

Models should use pluralize when computing inverse names #88

Closed
catmando opened this issue Dec 11, 2018 · 1 comment
Closed

Models should use pluralize when computing inverse names #88

catmando opened this issue Dec 11, 2018 · 1 comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Milestone

Comments

@catmando
Copy link
Contributor

Not simplistic removal of s from end of name.

Good test is has_many :criteria

this should fix it:

module ActiveRecord
  module Associations
    class AssociationReflection
      def initialize(owner_class, macro, name, options = {})
        owner_class.reflect_on_all_associations << self
        @owner_class = owner_class
        @macro =       macro
        @options =     options
        @klass_name =  options[:class_name] || (collection? && name.camelize.singularize) || name.camelize
        @association_foreign_key = options[:foreign_key] || (macro == :belongs_to && "#{name}_id") || "#{@owner_class.name.underscore}_id"
        @source = options[:source] || @klass_name.underscore if options[:through]
        @attribute = name
      end
  end
end
@catmando catmando added the bug Something isn't working label Dec 11, 2018
@catmando catmando added this to the alpha1.3 milestone Dec 11, 2018
@catmando
Copy link
Contributor Author

closed see batch7/association_naming_spec.rb for example

@catmando catmando added the ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch label Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Projects
None yet
Development

No branches or pull requests

1 participant