| Class | Criteria::TableAlias |
| In: |
lib/table_alias.rb
|
| Parent: | Object |
| alias | [R] | |
| joins | [R] | |
| model_class | [R] | the class of the ActiveRecord model represented by this TableAlias |
| query | [R] | the root query to which this TableAlias belongs |
# File lib/table_alias.rb, line 17
17: def join(attribute, options={}, &block)
18:
19: attribute = attribute.to_s
20:
21: new_join = Join.new(attribute, self)
22: (@joins ||= []) << new_join
23: (@joins_hash ||= {})[attribute] = new_join
24:
25: join_alias = (options[:as] || attribute).intern
26:
27: # we cannot add a join if a method with that name already exists
28: if respond_to? join_alias
29: raise "Invalid join name. A method #{join_alias} already exists. Use :as when defining the join"
30: end
31:
32: add new_join
33:
34: yield new_join if block_given?
35:
36: new_join
37: end