search for: update_all

Displaying 20 results from an estimated 40 matches for "update_all".

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...
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: Ta...
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 bel...
2010 Jul 14
1
ActiveRecord::Observer, update_all and has_many
...o 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 HasManyAssociation delete_records method uses update_all to update the record. update_all bypasses the normal call backs and therefore also bypasses the Observer. Is there a way to get an Observer to observe update_all calls? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "R...
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 sql UPDATE without saving all the attributes (ie, updating only the attri...
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...
2005 Nov 30
0
Passing variables with update_all
I''d like to produce an SQL update along the lines of: UPDATE companies SET category2={newcategory} WHERE (category2 = {oldcategory}) At the moment I''ve got: ctype = params[:ctype] Company.update_all("category2=ctype", "category2=ctype") At present this returns a StatementInvalid: Unknown column ''ctype'' in ''where clause'': UPDATE companies SET category2=ctype WHERE (category2 = ctype) Can anyone tell me how I can pass the variable succes...
2006 May 31
1
Help enhancing acts_as_nested_set
...self.class.transaction { child[parent_column] = self.id right_bound = self[right_col_name] child[left_col_name] = right_bound child[right_col_name] = right_bound + 1 self[right_col_name] += 2 self.class.update_all( "#{left_col_name} = (#{left_col_name} + 2)", "#{left_col_name} >= #{right_bound}" ) self.class.update_all( "#{right_col_name} = (#{right_col_name} + 2)", "#{right_col_name} >= #{right_bound}" ) self.save chil...
2007 Oct 12
2
missing attribute: reorder
...sync.png"), { :controller => ''manage_plan_procedures'', :action => ''reorder'', :id => plan_procedure.id}, {:border => 0, :title => "Reorder Cases", :class => "image_link"}) %> <% end %> I am setting this with an update_all PlanProcedure.update_all("reorder = 1","procedure_id = #...@procedure.id}") and the reorder field is properly being set. Has anyone seen something like this before and have any ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message because y...
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 latest_action = Action.find(:first, :conditions => ["deleted <> 1 and inquiry_id = ?", self.inquiry_id], :order => "action_date DESC, id DESC")...
2006 Jan 23
4
ActionRecord: how to update many records in one statement
Hello, I am trying to edit and update all records of table ?intersts? (id, name, description) on one page and has no good idea how to do it right, when updating one record per page it?s ok The question is: what statement instead Interest.update_all(params[:interest]) in controller need to use to successfully update the database table by data passing to controller in parameter ?interest?? Looked for solution in other places didn?t make any results, please help if you know how to do it. Thanks a lot. Sorry for such ugly piece of code, but...
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 c...
2009 Jun 07
17
ActiveRecord Classes
...iveRecord::Base # METHOD that define which URL to parse # METHOD that parses the data into an instanced variable called @rows # METHOD that should be updating my database table called "rushing_offenses" # Update Rushing Offense def update_rushing_offense for i in 0..@numrows-1 update_all(:name => @rows[i][0], :games => @rows[i][1]) puts "Updating Team Name = #{@rows[i][0]}." end end end The scraper.rake file contains: desc "This task will parse data from ncaa.org and upload the data to our db" task :scraper => :environment do offensive_r...
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 save...
2005 Mar 10
10
Some Basic Questions
...on => ''index'' And when I go to the root of my project I get the default startup page for a new rails application... the index.html file. What am I doing wrong? 3) Instead of destroying an entry I want to update the deleted field I have to equal 1. Should I use the update or update_all methods and does anyone have examples of them being used :-). Thanks for your guys help. I know they are mundane questions. But I am only on my third day of rails... and OO languages come to think of it. :-)
2005 Dec 31
4
saving a collection
...eems 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 the update_all command is right for this, as it understand it... Do I just have to iterate through the collection, issuing a save command on each object? Thanks for any advice... Shelby -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/...
2006 Mar 24
6
Should counter_cache fields be saved in the database?
As far as I can tell, the counter_cache option on a belongs_to model doesn''t actually save anything in the database. For example, I have the following models: class Parent < ActiveRecord::Base has_many :children, :conditions => "deleted_at IS NULL" end class Child < ActiveRecord::Base belongs_to :parent, :counter_cache => true end With the following
2006 Aug 05
10
Converting mysql to postgres
Hi, Anyone got any cool tricks for converting a Rails site (in this case, a typo installation) from a mysql database to a postgresql database? I''ve got it almost working -- I''m doing a SQL dump from mysql and loading it into postgres. However, mysql does booleans as a tinyint with 0 = false and 1 = true. When I try to import that into a postgres database that expects booleans
2006 May 30
2
acts_as_queue
wondering if anyone tried this patch. (i havent, seeing as its 1228 lines long, 10 months old, and cant take serious a patch many orders larger than competing web frameworks) in many cases i want to keep about 10 things around, eg recent searches, new items (spanning multiple classes), referers, page views, without logging them for perpetuity. so i guess this isnt a normal queue, more like a
2008 Feb 13
4
Migration Issues: Can't update newly added column values
Hello everyone, just wondering if anyone can help me with a migrations question here. Using: rails 2.0.2 ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin] mysql 5.0.45 Platform: windows xp The problem: ---------- I created a migration that is designed to add a column named "deleted_at" (timestamp) and then remove a column named "is_deleted" (boolean). The idea is to