ruby on rails - View association object -
hi have table called contractors acting users model logging system. have second table called employees. have created relationship between 2 tables. contractors has_many employees , employees belong_to contractor.
the employee table has field contractor id foreign key.
when contractor logs how can set view show him employees belong him
thanks in advance!
i don't know how authentication works, sou should have current_user
helper retrieves logged in user session. devise gem, example, creates automatically.
@employees = current_user.employees
Comments
Post a Comment