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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -