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,
<% @resource.projects.each do |project| %>
Project Title
Project Type
<% end %>
I’ve to write controller ,but failed to
def updateall
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.
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,
Hi!
def yourmethodname @all_project_id = @resource.projects.collect{|single_project|single_project.id}
if request.post?
for project_id in @all_project_id
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,
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.