Skip to content

Models should use pluralize when computing inverse names #88

Closed
@catmando

Description

@catmando

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-to-releaseInternal Use Only: Has been fixed, specs passing and pushed to edge branch

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions