사용자 테이블이 있습니다. "user_type"필드를 포함합니다. 는 내가 user.rb 파일에 다음 범위 stmts을 추가 :RoR 범위 문제
scope :uemployee, where(:user_type => 'employee')
scope :uclient, where(:user_type => 'client')
scope :ucontractor, where(:user_type => 'contractor')
내가보기를 생성하고 나는 그가 직원을 나열하고 싶습니다. 내가 잘못 뭐하는 거지
: 나는 "NilClass 전무에 대한 정의되지 않은 메서드`uemployee '을"얻을
<% @users.uemployee.each do |user| %>
을하지만, 다음은 코드는 내가 사용하는 것을 시도하고있다?
<% User.uemployee.each do |user| %>
그러나 이것은 나쁜 관행으로 간주됩니다 :
감사
당신의 orm은 무엇입니까? – apneadiving
이것은 orm입니까? belongs_to : 클라이언트 has_many : assigned_worequests, : class_name => "wrequest", : foreign_key => "employee_id" has_many : wrequests has_many : 상태 – Reddirt