The below code deletes all the task users and inserts the new task users
by getting the ids from the UI.
I have two questions:
1) Is there any way to delete all the records in a single statement.
If we put task_users = [], generating the delete statement for every
record
2) Is there any way to do the batch insert? The below code generates
more insert statement
@task = Task.find(params[:task_id])
task_users = []
params[:ids].split(", ").each do |court_user_id|
task_users << TaskUser.new(:court_user_id => court_user_id)
end
Task.transaction do
@task.task_users = task_users
@saved = @task.save
end
--
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
-~----------~----~----~----~------~----~------~--~---