# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 17 def primary_key quote_table_name association.active_record_primary_key end
class Surus::JSON::HasAndBelongsToManyScopeBuilder
Public Instance Methods
association_foreign_key()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 21 def association_foreign_key quote_column_name association.association_foreign_key end
association_primary_key()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 33 def association_primary_key quote_column_name association.association_primary_key end
association_table()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 29 def association_table quote_table_name association.klass.table_name end
foreign_key()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 25 def foreign_key quote_column_name association.foreign_key end
join_table()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 13 def join_table quote_table_name association.join_table end
primary_key()
click to toggle source
scope()
click to toggle source
# File lib/surus/json/has_and_belongs_to_many_scope_builder.rb, line 4 def scope s = association .klass .joins("JOIN #{join_table} ON #{join_table}.#{association_foreign_key}=#{association_table}.#{association_primary_key}") .where("#{quote_table_name outside_class.table_name}.#{primary_key}=#{join_table}.#{foreign_key}") s = s.instance_eval(&association.scope) if association.scope s end