Hi all, I am unable to write updateall method for my application. I want to edit all projects from project table for particular resource and update them all at once. My 2 tables Resource ======id name info project ======id title type resource_id My view.rhtml as, <form action="../updateall/<%= @resource.id %>" method="POST"> <% @resource.projects.each do |project| %> <table border="1" > <tr> <td > <b>Project Title </b></td> <td> <input id="project_title[<%project.id %>]" name="project[title]" type="text" value="<%project.title %>"/> </td> </tr> <tr> <td width="50%"> <b>Project Type </b></td> <td> <input id="project_type[<%= project.id %>]" name="project[type] type="text" value="<%= project.type %>"/> </td> </tr> </table> <% end %> <input type="submit" value="Update" /> </form> I''ve to write controller ,but failed to def updateall end Please help me out. 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-/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 -~----------~----~----~----~------~----~------~--~---
Hi! Unless i am missing something you want to make changes and save them back. I think you can collect all the ids of the projects using the collect statement in Ruby and then run a loop if request.post? with these id and for each textarea you can just use the Modelname.update method. Thanks and regards, Swanand. On 4/30/07, Rahul Ha <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi all, > I am unable to write updateall method for my application. > I want to edit all projects from project table for particular resource > and update them all at once. > > My 2 tables > > Resource > ======> id > name > info > > project > ======> id > title > type > resource_id > > > My view.rhtml as, > > <form action="../updateall/<%= @resource.id %>" method="POST"> > <% @resource.projects.each do |project| %> > <table border="1" > > <tr> <td > <b>Project Title </b></td> <td> <input id="project_title[<%> project.id %>]" name="project[title]" type="text" value="<%> project.title %>"/> </td> </tr> > > <tr> <td width="50%"> <b>Project Type </b></td> <td> <input > id="project_type[<%= project.id %>]" name="project[type] type="text" > value="<%= project.type %>"/> </td> </tr> > > </table> > > <% end %> > <input type="submit" value="Update" /> > </form> > > > I''ve to write controller ,but failed to > def updateall > > end > > Please help me out. > > 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-/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 meant ids of all the projects for that particular resource. On 4/30/07, swanand deodhar <swanand.blms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi! > Unless i am missing something you want to make changes and save them > back. I think you can collect all the ids of the projects using the collect > statement in Ruby and then run a loop if request.post? with these id and > for each textarea you can just use the Modelname.update method. > Thanks and regards, > Swanand. > > > On 4/30/07, Rahul Ha <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote: > > > > > > Hi all, > > I am unable to write updateall method for my application. > > I want to edit all projects from project table for particular resource > > and update them all at once. > > > > My 2 tables > > > > Resource > > ======> > id > > name > > info > > > > project > > ======> > id > > title > > type > > resource_id > > > > > > My view.rhtml as, > > > > <form action="../updateall/<%= @resource.id %>" method="POST"> > > <% @resource.projects.each do |project| %> > > <table border="1" > > > <tr> <td > <b>Project Title </b></td> <td> <input id="project_title[<%> > project.id %>]" name="project[title]" type="text" value="<%> > project.title %>"/> </td> </tr> > > > > <tr> <td width="50%"> <b>Project Type </b></td> <td> <input > > id="project_type[<%= project.id %>]" name="project[type] type="text" > > value="<%= project.type %>"/> </td> </tr> > > > > </table> > > > > <% end %> > > <input type="submit" value="Update" /> > > </form> > > > > > > I''ve to write controller ,but failed to > > def updateall > > > > end > > > > Please help me out. > > > > 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-/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 -~----------~----~----~----~------~----~------~--~---
Swanand Deodhar wrote:> i meant ids of all the projects for that particular resource.Swanand, Thanks for your reply. Actually I am new to Ruby and web technologies too. So sometime not understand the terms. Ok. you mean say, I need to post all my project ids for particular user, collect them in controller, But how to update that row. I am unable to get Modelname.update term. Regards, -- 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 -~----------~----~----~----~------~----~------~--~---
Hi!
def yourmethodname
@all_project_id
@resource.projects.collect{|single_project|single_project.id}
if request.post?
for project_id in @all_project_id
Project.update(project_id,
:whatever_attribute => params[: #Give the
name of the textbox with the
project_id appended to it]
end
end
end
Hope this helps,
Thanks and regards,
Swanand
On 4/30/07, Rahul Ha
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Swanand Deodhar wrote:
> > i meant ids of all the projects for that particular resource.
>
> Swanand,
> Thanks for your reply. Actually I am new to Ruby and web technologies
> too. So sometime not understand the terms. Ok.
> you mean say, I need to post all my project ids for particular user,
> collect them in controller, But how to update that row. I am unable to
> get Modelname.update term.
>
> Regards,
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---
Swanand Deodhar wrote:> Hi! > def yourmethodname > @all_project_id > @resource.projects.collect{|single_project|single_project.id} > if request.post? > for project_id in @all_project_id >thanks swanand, That was good help Regards, -- 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 -~----------~----~----~----~------~----~------~--~---