I have this problem. I have a Job table in my db, and each job has many steps (table Step). Is not possible to know how many steps a job has until it is created. So when I create a new job I have a problem: I can not have a step_id in my Job table, because it can be one step or more. What can I do? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 22, 9:16 am, John Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have this problem. > I have a Job table in my db, and each job has many steps (table Step). > Is not possible to know how many steps a job has until it is created. So > when I create a new job I have a problem: I can not have a step_id in my > Job table, because it can be one step or more. > What can I do?If jobs has_many :steps then the jobs table doesn''t have a step_id at all: steps have a job_id column. Fred> -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, I know. If I can create a job first I have no problem, but I can''t do that. I want to be able to create a job and, at the same time, create as many steps as I want. I would use AJAX in order to create new step fields, but if I have not created a job I can have any relation between a step and a job. Any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
HAii.. sorry my English is very bad I don''t what you want... but I have idea why do u not use 3 model / 3 table? table job id table join_job_step job_id step_id table step id this is "has_many_and_belongs_to" (same), but Don''t use "has_many_and_belongs_to". Model: * job has_many :join_job_steps * join_job_step belongs_to :job * step has_may :join_job_steps So, when u create job or step, u don''t need step_id or job_id.. And if u want make relation, just create join_job_step. May be it can help u... Thank you -- Wu You Duan(Anton effendi) Senior Rails Developer www.kiranatama.com On Mon, Dec 22, 2008 at 4:29 PM, John Smith < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thanks, I know. > If I can create a job first I have no problem, but I can''t do that. I > want to be able to create a job and, at the same time, create as many > steps as I want. I would use AJAX in order to create new step fields, > but if I have not created a job I can have any relation between a step > and a job. > Any ideas? > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a lot, but I think that does not solve my problem, because I need to create a job to make a relation between the job and it steps. With that, I can create steps without a job, but how can I make relation between these steps and the job. Should I have to take the last steps and make a relation with the job I am creating? I think this is a bas solution. Any other ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think what you''re looking for is the build method, something along the lines of @job.steps.build in your controller. Take a look at the complex form railscasts by Ryan Bates: http://railscasts.com/episodes/73-complex-forms-part-1 (go to parts 2 and 3 after you''re done with part 1). On Dec 22, 5:56 am, John Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks a lot, but I think that does not solve my problem, because I need > to create a job to make a relation between the job and it steps. With > that, I can create steps without a job, but how can I make relation > between these steps and the job. Should I have to take the last steps > and make a relation with the job I am creating? I think this is a bas > solution. > Any other ideas? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Harold wrote:> I think what you''re looking for is the build method, something along > the lines of @job.steps.build in your controller. > > Take a look at the complex form railscasts by Ryan Bates: > http://railscasts.com/episodes/73-complex-forms-part-1 > (go to parts 2 and 3 after you''re done with part 1). > > > On Dec 22, 5:56�am, John Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks a lot. I will check it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sorry to say, but i think what you really need is a guide on data- modeling. if a job has many steps, the job has to be there before you create any steps, as every step belongs to exactly one job. now, you say you have to create a job and its steps at the same time. why don''t you think of a way to solve that? look into your controller, there is always a solution. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---