method
joins
v3.0.0 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
joins(*args)public
No documentation available.
# File activerecord/lib/active_record/relation/query_methods.rb, line 45
def joins(*args)
args.flatten!
clone.tap {|r| r.joins_values += args if args.present? }
end 1Note
Options
I came across the following situation An article has a history of friendly url being that the foreign key that represents the value of the article's id in the table is called Friend url_id then in that case:
Article.joins("INNER JOIN friends ON articles.id = friends.url_id").where("friends.url like ? ", url)
if the column url_id was renamed for artigo_id would be easier
Article.joins(:friend).where("friends.url like ? ", url)