Hi,
I am still on my first Rails application which consists of several models and their controllers and views. Recently, I added user authentication to the project and have been able to make it work so far. For all views, I have a common layout file "qalayout.html.erb". This layout file contains the view logic for login/logout. It also allows user (if the user is logged in) to submit a new job to the site using a form in a div that is collapsible.
Now, I also want to include another collapsible div in which all jobs for that user are listed. I have a User model and a Job model. The Job model has a "user_id" foreign key. So, far I have everything else working. Please note that these functionalities should be available to the user no matter what view they are at, if they are logged in, hence I have included the viewing logic in the common layout file.
What is the best way to go about listing the jobs? Should the controller method be defined in the ApplicationController as follows?
def userjobs @jobs = Job.find(:all, :conditions => { :user_id => params[:userid] }) end
How can I get all jobs to be listed from the qalayout.html.erb file?
Many thanks!
Amrita