similar to: Reduce Number of Queries When Using ActiveRecord

Displaying 20 results from an estimated 500 matches similar to: "Reduce Number of Queries When Using ActiveRecord"

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 Sep 23
9
Code reviews: my dumb use of acts_as_commentable (newbie)
With the help of several heroes here yesterday I beat my way into a working solution to adding comments to one or more models in my application using acts_as_comentable. Great plugin, but my implementation is lame. I need enlightenment. I have users who log in. For several views I want to let them add comments. Enter act_as_commentable which does just this -- it''s polymorphic, so you
2006 Sep 07
6
form_for - Child object - how to set parent id
Hi All, I am just trying to learn ruby/rails so please don''t flame me if this is a stupid question. As a learning project I decided to create my own blog using ROR. I have created a controller that shows paged blog entries, and below each blog is a list of comments along with a form alowing the user to add a new comment. To create the form for the comment entry I used form_for
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
2009 Aug 16
5
any help with captcha in my comments ?
this is my error: Processing ApplicationController#create (for 127.0.0.1 at 2009-08-17 00:57:56) [POST] Parameters: {"comment"=>{"name"=>"asdasd", "body"=>"asdasd"}, "commit"=>"Add Comment", "post_id"=>"19",
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
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 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
2007 May 31
4
Sample Merb App
I put together a sample app to help people learn Merb: http://svn.depixelate.com/applications/invoice_tracker/ I also blogged about it here: http://depixelate.com/2007/5/31/taking-merb-for-a-spin -- Zack Chandler http://depixelate.com
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
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??
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
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
2006 Aug 10
6
save without commit ?
How do I get ''save'' to execute without commit? I have tried: ActiveRecord::Base.connection.begin_db_transaction # do some stuff that doesn''t issue a database COMMIT statement # then: @myObject.save # this issues a COMMIT but it shouldn''t! Shouldn''t it wait until I''ve called: ActiveRecord::Base.connection.commit_db_transaction ? what am
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 Apr 03
4
How to fake composite primary keys?
I know ActiveRecord doesn''t support composite primary keys, but I need to use one, and I need it ASAP. I don''t need any composite foreign keys, luckily; what I have is a table that stores old versions of rows in another table, so the composite key is an id + date stamp. Would someone tell me a hack I can use to support this? -- View this message in context: