Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 我正在尝试用参数加入ruby。我犯了一个错误_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 我正在尝试用参数加入ruby。我犯了一个错误

Ruby on rails 我正在尝试用参数加入ruby。我犯了一个错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,控制器代码: @fte_new_hires = Bvadmin::EmployeeApplicant.fte_new_hires(next_startdate, next_enddate) 型号代码: class Bvadmin::EmployeeApplicant < Bvadmin::Record self.table_name = "BVADMIN.EMPLOYEE_APPLICANTS" self.primary_key = :applicant_id has_man

控制器代码:

@fte_new_hires = Bvadmin::EmployeeApplicant.fte_new_hires(next_startdate, next_enddate)
型号代码:

class Bvadmin::EmployeeApplicant < Bvadmin::Record
  self.table_name = "BVADMIN.EMPLOYEE_APPLICANTS"
  self.primary_key = :applicant_id
  has_many :employeeapplications

  scope :fte_new_hires, -> (startdate,enddate) {EmployeeApplicant.joins   (:employeeapplications).where("confirmed_eod >= ? and confirmed_eod <= ?", startdate, enddate).order('name ASC') }
end
class Bvadmin::employeeapplicator范围:全职员工新员工,->(开始日期,结束日期){employeeapplicator.joins(:employeeapplications)。其中(“confirfied_eod>=?and confirfied_eod您的类名是'Bvadmin::employeeappender',但您在范围中使用了'employeeappender',因此它试图在此类'Bvadmin::employeeappender'中查找常量'employeeappender',这就是为什么出现'uninitialized constant Bvadmin::employeeappender::employeeappender'错误的原因

 joins is equivalent to self.joins which is equivalent to Bvadmin::EmployeeApplicant.joins
这个类中的self是Bvadmin::employeeapplicator,所以你可以像下面这样做

已更新

 scope :fte_new_hires, -> (startdate,enddate) {joins(:employee_applications).where("confirmed_eod >= ? and confirmed_eod <= ?", startdate, enddate).order('name ASC') }

我替换了这一行,但当我尝试这样做时:所以我的另一个模型是:class Bvadmin::EmployeeApplication(startdate,enddate){加入(:bvadmin::EmployeeApplications)。其中(“已确认的eod>=”和已确认的eod错误是什么?:bvadmin::EmployeeApplications不是关联,它应该是joins(:employee_applications)。我在代码中也更新了关联,可能这就是您现在遇到的问题。
 has_many :employee_applications, class: "Bvadmin::EmployeeApplicantion"