[Rails] Re: howto implement a join table

2011-02-16 Thread rogi
implemented Ar Chrons idea. Now I wanted to replace the text fields with select boxes. They look right and let me select values, but the table fields for worker_id and course_id don't get filled: [# <%= select_tag 'worker_id', options_for_select(Worker.all.collect { | w| [w.first_name+"

[Rails] Re: howto implement a join table

2011-02-15 Thread Ar Chron
rogi wrote in post #981715: > Hi There > > I have a table for the names of my workers and a table with the > courses they have attended. > Now I try to create a join table to see which workers attended what > courses. > Assuming you have completed something like this: rails g scaffold worker first_

Re: [Rails] Re: howto implement a join table

2011-02-15 Thread Chris Kottom
I would do: 1. rails generate model worker [ definition of model attributes ] 2. Modify migration file for workers table as needed 3. Modify app/model/worker.rb to add has_and_belongs_to_many :courses 4. rails generate model course [ definition of model attributes ] 5. Modify migrat

Re: [Rails] Re: howto implement a join table

2011-02-15 Thread Colin Law
On 15 February 2011 10:50, rogi wrote: > > On 15 Feb., 11:29, Lorenzo Brito Morales > wrote: >> With Active record , its already link it, i mean, whit @worker.courses >>  you have a collection of what courses has a worker take it. >> With scaffold is to set up custom code to controller/view/model

Re: [Rails] Re: howto implement a join table

2011-02-15 Thread Lorenzo Brito Morales
With you create the structure of rails, the model part, has just that part done for you, if you want to find relationchips, just go with models,, lest say that you have 3 tables, one for workes and another for courses and the third that has one worker and one course,in your manageWorkersCourses.htm

[Rails] Re: howto implement a join table

2011-02-15 Thread rogi
On 15 Feb., 11:29, Lorenzo Brito Morales wrote: > With Active record , its already link it, i mean, whit @worker.courses >  you have a collection of what courses has a worker take it. > With scaffold is to set up custom code to controller/view/model . I dont now about active record! I mean @work