Table plus with Instance object error

16 views
Skip to first unread message

Vivek Sampara

unread,
Jan 13, 2013, 9:55:30 PM1/13/13
to hobo...@googlegroups.com
hi guys, 

Im working on getting 2 custom tables on admin users index and made 2 instance objects on the admin users controller this way 

def index
    hobo_index

    @hospital_case_managers = User.find(:all, :conditions => { :case_manager_type_id => CaseManagerType.find_by_name('Hospital').id }) 
 
    @insurance_case_managers = User.where(:case_manager_type_id => CaseManagerType.find_by_name('Insurer').id) 
end

and on index page im doing this 

  <content-body:>
  <h4>Hospital Case Managers</h4>
  <table-plus with="&@hospital_case_managers" fields="name, phonenopri, phonenosec, email_address, hospital">
   <empty-message:>No users match your criteria</empty-message:>
  </table-plus>
  <br />
  <h4>Insurer Case Managers</h4>
  <table-plus with="&@insurance_case_managers" fields="name, phonenopri, phonenosec, email_address, insurer">
   <empty-message:>No users match your criteria</empty-message:>
  </table-plus>
  </content-body:>

and i get this error called "Undefined method member_class for Nil:nil "

I replaced the same table plus with the code to pull objects from the view directly this way 

  <table-plus with="&User.find(:all, :conditions => { :case_manager_type_id => CaseManagerType.find_by_name('Hospital').id })" fields="name, phonenopri, phonenosec, email_address, hospital">
   <empty-message:>No users match your criteria</empty-message:>
  </table-plus>

  <table-plus with="&User.find(:all, :conditions => { :case_manager_type_id => CaseManagerType.find_by_name('Insurer').id })" fields="name, phonenopri, phonenosec, email_address, insurer">
   <empty-message:>No users match your criteria</empty-message:>
  </table-plus>

What should my code be if im planning to pull the object from the controller and not at the view ? 

Thanks
Vivek




Bob Sleys

unread,
Jan 14, 2013, 1:45:05 PM1/14/13
to hobo...@googlegroups.com
I believe the problem is in your controller

def index
    hobo_index

    @hospital_case_managers = User.find(:all, :conditions => { :case_manager_type_id => CaseManagerType.find_by_name('Hospital').id }) 
 
    @insurance_case_managers = User.where(:case_manager_type_id => CaseManagerType.find_by_name('Insurer').id) 
end

should be

def index
    hobo_index do
        @hospital_case_managers = User.find(:all, :conditions => { :case_manager_type_id => CaseManagerType.find_by_name('Hospital').id }) 
 
       @insurance_case_managers = User.where(:case_manager_type_id => CaseManagerType.find_by_name('Insurer').id) 
   end
end

Bob
Reply all
Reply to author
Forward
0 new messages