Now suppose if the Activity has field name Now for a Ticket with
id=1 say there are 10 activities So to update name of all activities I
can directly wite the sql statement
update activities set name=‘somename’ where ticket_id=1
So I am writing this like
ticket = Ticket.find(1)
ticket.activities.each do |a|
a.update_attribute(:name => ‘somename’)
end
But what about the performance Is both the above query and the ruby
code has same performance What is actually the generated sql for the
ruby code
Or Am I wrong? Is there any other way of doing this same like sql
above?
Hi
I tried like
Activity.update_all(“name=‘hi’”, :conditions => [“ticket_id =?”,1])
But getting error
ActiveRecord::StatementInvalid: RuntimeError: ERROR C42703 Mcolumn
activities.conditions does not exist P42 Fparse_func.c
L1104 Runknown_attribute: UPDATE “activities” SET name=‘hi’ WHERE
(“activities”.“conditions” IN (E’ticket_id =?’,1))
Could you please correct the syntax
Sijo