Flowdock
method

aliased_table_name_for

Importance_0
v2.2.1 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation
aliased_table_name_for(name, suffix = nil) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations.rb, line 2171
              def aliased_table_name_for(name, suffix = nil)
                if !parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{name.downcase}\son}
                  @join_dependency.table_aliases[name] += 1
                end

                unless @join_dependency.table_aliases[name].zero?
                  # if the table name has been used, then use an alias
                  name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}"
                  table_index = @join_dependency.table_aliases[name]
                  @join_dependency.table_aliases[name] += 1
                  name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0
                else
                  @join_dependency.table_aliases[name] += 1
                end

                name
              end
Register or log in to add new notes.