I just dove into Rails 2.0. I know the basics such as what MVC is and how to code in Ruby. I can't seem to get relationships working in rails though.
My application has four models and controllers. They are:
The application just is a job logging site. The Use case would be like, you would see a screen with a menu with all the users, machines, and tasks (eg backup, defrag, virus scan). You would choose who the user is, what machine they worked on and what tasks were done on that machine and the date on which it was done.
Example output would be:
User | date | Machine | Task 1 | Task 2 | .... | Task N
bob | mmyydd | machine1 | done | not done | .... | done
I would like to add more users, machines and tasks in the future. My database is like this:
user_id |username |password |firstname |lastname
machine_id | machine_name
task_id | task
job_id | date | user_id | machine_id | task_id
In the jobs Table, user_id, machine_id and task_id will point to the appropriate users, machines, tasks table rows.
Now I did the first part and created Users, Machines and Task scaffold and I have populated the tables with the data. Now, how do I get the Jobs to work in order to put everything together?
I would need to create Jobs/new, Jobs/index, and Jobs/edit actions. The Jobs/new action would have a form that would pull the information from Machines, Users, and Tasks and show them.
So I went to job controller's index action and added:
in order to get the @ instance variables to get all the data from jobs, machines, users, tasks
@jobs = Jobs.find(:all)
@machines = Machine.find(:all)
@users = User.find(:all)
@tasks = Task.find(:all)
then I went to views and now I'm thinking I can create a form with this information that can submit to the database.
Then I could just display this information.
Am I basically on the right track?