I have been working with Ruby on Rails for about a week. I am trying to figure out a problem. I have a small relational database. resources :client do resources :department do resources :task end end What I want is to be able to add tasks while looking a specific "show" of a department. /app/view/department/show.html.erb <h1> Department: </h1> <%= render @department %> <h2> Tasks: </h2> <%= render @department.tasks %> <h2> Add a Task: </h2> INSERT FORM HERE now I am likely to want to move this off as a partial under the /tasks but at a basic level how do I create this form? In order to do this I know I have to define the create method in my tasks controller and then create a <%= form_for .... %> I am just struggling with this. Please help! Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hi John, On Thu, Sep 20, 2012 at 1:52 PM, John B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have been working with Ruby on Rails for about a week. > > I am trying to figure out a problem. > > I have a small relational database. > > resources :client do > resources :department do > resources :task > end > end > > What I want is to be able to add tasks while looking a specific "show" > of a department. > > /app/view/department/show.html.erb > > <h1> Department: </h1> > <%= render @department %> > <h2> Tasks: </h2> > <%= render @department.tasks %> > <h2> Add a Task: </h2> > INSERT FORM HERE > > now I am likely to want to move this off as a partial under the /tasks > but at a basic level how do I create this form? > > In order to do this I know I have to define the create method in my > tasks controller and then create a <%= form_for .... %> I am just > struggling with this. > > Please help! > > Thanks > >Success in Rails comes most quickly to those with strong Google Fu. rails 3 form_for nested resources yields good results. You might want to start with this one: http://stackoverflow.com/questions/2034700/form-for-with-nested-resources Best regards, Bill -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Bill - Thanks so much for your response. I spent a good portion of yesterday on google trying to solve this. I was dancing around the solution. I appreciate your help. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hi John, On Fri, Sep 21, 2012 at 7:37 AM, John B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Bill - > > Thanks so much for your response. I spent a good portion of yesterday on > google trying to solve this. I was dancing around the solution. I > appreciate your help. > >You''re welcome. And welcome to the Rails community! Best regards, Bill -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.