similar to: ActionRecord: how to update many records in one statement

Displaying 20 results from an estimated 300 matches similar to: "ActionRecord: how to update many records in one statement"

2006 Jun 01
2
update_all broken in postgres?
Hi has anyone managed to use update_all with rails on postgres? In my setup, it does not work: >> @keyword.update_all(myupdates) NoMethodError: undefined method `update_all'' for #<Keyword:0xb7ac4670> from /home/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1786:in `method_missing'' from (irb):14 I checked that the base.rb
2006 Jul 06
4
update_all Not Incrementing lock_version
Shouldn''t update_all be updating lock_version? As you can see from my console session below, it is upating the record (changed running attribute to true and returned 1 to show 1 recored was updated). But it did not increment lock_version. And optimistic locking is working correctly otherwise. As you can see below, lock version = 562 before and after the update_all call but it is
2008 Jul 02
3
update_all not changing updated_at
Hi everyone- Model.update_all works and changes the records, but it''s not changing the updated_at field. Am I doing something wrong or is this by design? Thanks, Dino --~--~---------~--~----~------------~-------~--~----~ 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
2007 Oct 12
2
missing attribute: reorder
I am trying to use an integer object as a flag item for displaying a link on a page called reorder that is a column in my PlanProcedures table. I''m getting an error that says The Header is NoMethodError in Manage_plan_procedures#list missing attribute: reorder Here is what my model looks like: >> PlanProcedure.column_names => ["id", "plan_id",
2007 Sep 21
1
Temporary disabling after_update
Hi, I am trying to replace my old database trigger with ActiveRecord callbacks in rails. I have a model like following: class Action < ActiveRecord::Base belongs_to :inquiry def after_update #clean up all action associated with the inquiry. Action.update_all("latest = ''''", ["inquiry_id = ?", self.inquiry_id]) #find the latest action
2006 Apr 11
6
Reduce Number of Queries When Using ActiveRecord
I have a controller method called update_all that grabs parameters for about 30 form fields and saves them to the database. My current code looks to see if there is a string in params[] for each form field (two fields for each SelfEvaluationItem) and saves the updated self_evaluation_answer if a string is available. Since this is iterated code, I am almost certain that this generates 30 or so
2007 Sep 07
6
ActiveRecord::Base#update_all expected behaviour
Hi I noticed that if in my code I use the following: Photo.update_all("title = ''Ruby rocks'' ", "id IN (#{@photo_ids})") All my objects are properly updated but none of the filters/callbacks are triggered. Is that what''s expected? I have a before_update filter set on the Photo class and it gets totally ignored, I guess the only way to solve this
2006 May 31
3
class does not inherit (?) ActionRecord::Base
Hi. I''m a newbie at this, so please bear with me. I have several classes which model several corresponding tables. All of them seem to work except one. I have not made many modifications from the scaffold templates. However, with one class, Log, all methods give me the following type of error NoMethodError in LogController#create undefined method `save'' for
2006 Mar 14
1
ActionRecord: Need for "identity"/"serial" columns?
I have a quick question about ActiveRecord and primary key value generation. Does it hurt to define my primary keys as "IDENTITY" (SQL server) or some equivalent database - managed id generation scheme (a la sequences in Oracle, etc.) since ActiveRecord is going to manage my id generation anyway. I''m thinking that for SQL server, even if you define your ids as
2007 Jan 20
0
actionrecord gem update produces Zlib::BufError
OS = MS-WinXPproSP2 with hotfixes up to date Dialogue: ---> C:\>gem update Updating installed gems... Bulk updating Gem source index for: http://gems.rubyforge.org Attempting remote update of actionmailer Install required dependency actionpack? [Yn] y Successfully installed actionmailer-1.3.1 Successfully installed actionpack-1.13.1 Installing ri documentation for actionmailer-1.3.1...
2009 Jun 07
17
ActiveRecord Classes
I''m having a little trouble with understanding how to work out the schematic for some of my classes using ActiveRecord when a file is in my lib directory: Brief example: Here''s the outline of the files in use: ....app ........controllers ............application_controller.rb ............rushing_offenses_controller.rb ........models ............rushing_offense.rb ....lib
2005 Mar 10
10
Some Basic Questions
Sorry I can''t access IRC from work so I hope you don''t mind me asking my newbie questions here: 1) I have the following code: @post = Post.find(@params[''id'']) @comments = Comment.find_all "post_id = #@params[''id'']", "created_on ASC" And I am have problems with the second line. I want to pass the id from my post to the
2005 Dec 31
4
saving a collection
Reading the Agile book, I can''t find a single command to save a collection. The save command seems to operate on only individual objects. Lets say I have a collection that I have received from a find_all command. I want to go through and change some attributes in various objects in the collection. Then I want to resave the whole collection back to the database. I don''t think
2006 May 31
1
Help enhancing acts_as_nested_set
I''m trying to enhance acts_as_nested_set. Well actually I already have, but I''ve done a hack up job of it. I would like to contribute these enhancements back, but I need a little help. I''m a complete newbie to this stuff. The only thing I new before coming into this project was vanilla HTML. So over the course of two weeks I''ve picked up Ruby, Rails, MySQL,
2011 Apr 24
2
False Positives In ActiveRecord Tests
Every now and then when I am working on making the SQL Server adapter pass all the ActiveRecord tests, I notice one that looks like a false positive in the core DBs. Here is one case in relations_test.rb. Can someone look at this and just tell me it is normal for other DBs and just odd for SQL Server? Or maybe it is just my understand of some SQL standard. I''m really not that SQL smart.
2010 Jul 14
1
ActiveRecord::Observer, update_all and has_many
Hi, I''m using an ActiveRecord::Observer to log users changing data in my application. However, I''ve noted that adding an item to a has_many relationship gets logged, but removing the item does not. That is: @product.users << user is logged, but: @product.users.delete(user) is not. I''ve dug into ActiveRecord and found that the underlying issue is that the
2006 Mar 13
1
adding custom cache field
Hello, I needed to add custom cache field for one of my application. I thought I will share the code showing how to do this. This code below creates and maintain a custom cache field, for keeping track of totals. Say, you have accounts, and for each account there are transactions (either deposit/withdrawal), and one will like to keep track of the total balance for an account. So, let there be a
2007 Jul 12
0
update_all for an AR instance
Is there anyway to call "update_attributes" where it updates only the attributes you specify with the update command. The only thing close to this is update_all where you have to specify the condition. So essentially you''d be stuck doing "id=#{obj.id}" as the condition. Are there any built in AR functions that allow you to update a particular object using straight
2006 Jun 01
4
how can I control when to commit a transaction?
hello it seems like this question has appeared a few times with no answer: how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to the database without committing each time? I tried setting ActiveRecord::Base.connection.begin_db_transaction before calling any action on my object, but as soon as myObject.save or myObject.update is called,
2006 Nov 04
0
need advice about race condition
There''s a field in my User model that sometimes needs bulk updates: User.update_all("cluster = #{new_cluster}", "cluster = # {current_cluster}") Now, suppose user with id 37 is affected by that particular update_all and updates his profile: 1. user 37 is read 2. update_all happens and changes 37''s cluster asynchronously 3. user 37 is saved