ruby lambda join

两个model:

class Course < ActiveRecord::Base
    has_many :curriculums

class Curriculum < ActiveRecord::Base
    belongs_to :course, :class_name=>"Course", :foreign_key => :course_id

 

 关联关系,在curriculum中查询:

scope :by_joins, lambda { |sd| {:joins => [:course], :conditions => {:courses => {:charge_type =>sd}}}}

 

joins参数就是关联的表,conditions是条件

你可能感兴趣的:(lambda)