我有一个用户表。它包含一个字段“user_type”。 我增加了以下范围支杆的user.rb文件:RoR范围问题
scope :uemployee, where(:user_type => 'employee')
scope :uclient, where(:user_type => 'client')
scope :ucontractor, where(:user_type => 'contractor')
我创建了一个观点,我想它列出他的员工。 这里是代码我试图使用方法:
<% @users.uemployee.each do |user| %>
但是,我得到“为无未定义的方法`uemployee”:NilClass”
我在做什么错?
感谢
什么是你的orm? – apneadiving 2012-04-26 20:11:14
这是orm吗? belongs_to:client has_many:assigned_worequests,:class_name =>“worequest”,:foreign_key =>“employee_id” has_many:worequests has_many:状态 – Reddirt 2012-04-26 20:54:01