similar to: Very weird counter_cache behavior

Displaying 20 results from an estimated 300 matches similar to: "Very weird counter_cache behavior"

2006 Jul 24
2
Thread.new with ActiveRecord under Mongrel vs. FastCGI
Hi All, I''m going to end up hosting a site on a server in a fastcgi environment, but I''ve been doing most of my development under mongrel. I have a bit of code that spawns a thread, and in the thread it makes some remote calls (openuri) and does some database inserts via activerecord. When I do this under FastCGI, everything appears to work as expected. When I do it under
2006 Feb 09
2
Strategies for updating multiple parts of the page with AJAX
Hi all, I have a layout that''s evolving, but it looks like there will be several divs. I''m trying to keep everything AJAX-y and avoid full page reloads. My problem is, if I have the login box in a div, I''m going to want two other divs to effectively "refresh" themselves to get data from the server now that there is a user logged in. I''m trying to
2008 Mar 25
7
Facebooker::Session::SessionExpired (Session key invalid or no longer valid)
Hi All, I''m having horrible problems with this exception, which seems to happen as soon as I access the session object. Does anyone know what the path is to recover from this? This post looked to be the most promising: http://rubyforge.org/pipermail/facebooker-talk/2007-December/000047.html And I followed all of the steps except switching my session store, and modifying the default
2006 Jul 11
1
counter_cache, has_many and belongs_to
I am a bit confused about counter_cache here. The API docs http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html say that only the belongs_to association can take the :counter_cache option. When I try to use it on a has_many I get an "unknown key(s): counter_cache" error. Why would this be the case? belongs_to means that this model has a field with an id
2005 Mar 01
0
acts_as_tree counter_cache
Hi List, I''m new to and hot on RoR. And I have a question regarding acts_as_tree and counter_cache. What methods actually update the counter_cache column? I''ve only really started the app so i''ve just got it set up so that I can select the parent node (from a list of nodes that exclude all descendants of the current node) with a radio buttoned list named and valued
2006 Jun 08
2
counter_cache is not looking for children_count with acts_as_tree
Hi there, the acts_as_tree API says that I can set a counter cache and that it will automatically increment the "children_count" column. I did that but when I create a new page it asks for a "pages_count" column instead. Here is the relevant part of page.rb model: class Page < ActiveRecord::Base acts_as_tree :order => :position, :counter_cache => true
2007 Jun 01
2
Ferret FileNotFound error after adding counter_cache to mode
I have a model that I''ve been indexing and searching with ferret with no problems. I just added a counter_cache for some voting functionality to the same model and now when I perform the voting fxn on an object from that model, I get the FileNotFound error as it looks for a file named "_1c_1.del" ...which breaks my voting function. I tried killing the server and my index
2009 Jun 01
4
counter_cache is making a redundant SELECT before UPDATE
Hi, I have the following code: Message, belongs_to :topic, :counter_cache => true topic = Topic.find_from_permalink(params[:id]) topic.messages.create(params[:message]) When the message gets created, then AR issues a supplemental SELECT to retrieve the message''s topic and then updates its messages_count. Why is that happening? If I do it manually: if
2006 Mar 12
2
counter_cache reference/tutorial
I''m trying to use counter_cache, but I''m not doing something right. It is unreliable and I keep having to correct it manually. Is there a good tutorial or reference on how to use it on-line? I have the AWDR book, but I need something more complete. TIA, Jeffrey
2006 Apr 12
0
counter_cache and updates
I''m trying to figure out how to use counter_cache. I''ve got Clients that have many Profiles. And I got things working so that when I add a new Profile, the profiles_count gets updated. profile = client.profiles.new(params[:profile]) profile.save However, I''m stuck trying to figure out how to deal with UPDATING a profile (moving it to a different Client). If I change
2006 Mar 08
0
How to add something similar to :counter_cache - :avg_cache
Hi, I was thinking of doing this with a stored procedure, but I thought it could be better implemented in Rails. I have several tables that hold a counter cache for other tables, which aren''t directly related. For example: Table ''schools'' has records that belong_to table ''counties'', and that table has records that belong_to table
2005 Dec 14
0
counter_cache not updating
Hi I'm using those 2 models: class Topic < ActiveRecord::Base has_many :articles, :order => :rank end class Article < ActiveRecord::Base belongs_to :topic, :counter_cache => true end The "counter_cache" column in the "topics" table does increase when adding a new article, but it does not update when updating article's topic or when deleting the
2008 Oct 31
0
Loading fixtures and counter_cache
Hi everyone, Does anybody know who is responsible for updating *_count columns (via :counter_cache) when creating the db and loading fixtures? In my case, the *_count elements remain zero! Thanks, Omid --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send
2006 Feb 03
2
acts_as_tree counter_cache behavior is different than API docs
Before I file a ticket, I''ll query ya''ll about this: The API docs for acts_as_tree''s counter_cache is to create a database column called "children_count" to hold the counter_cache. I have enabled this option in my model. While writing tests I wrote a test for creating children from the a parent: message = @forum_message["parent"].find child =
2006 May 22
3
STI, HABTM & counter_cache
Hello world... I have an interesting issue that the online docs aren''t helping me with. In my app I have 4 models Item < ActiveRecord Deal < Item Product < Item Category < ActiveRecord Item has_and_belongs_to_many :categories... On each category record I''d like to maintain a product_count and deal_count to increase performance. This doesn''t appear
2006 Aug 14
1
Relationship not saving
Hi All, I have a one to many relationship between images and gifts (one image can be assigned to multiple gifts): class ProductImage < ActiveRecord::Base has_many :gifts ... class Gift < ActiveRecord::Base belongs_to :product_image ... I''m trying to associate an image with a gift, and for the life of me ActiveRecord will not associate them. Here is some test code and 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 Feb 27
0
Better counter_caches
Hey everybody, Rails currently offers ''belongs_to :counter_cache'', which is a very basic replacement for count triggers: ":counter_cache - caches the number of belonging objects on the associate class through use of increment_counter and decrement_counter. The counter cache is incremented when an object of this class is created and decremented when it?s destroyed. This
2008 Apr 10
7
Facebooker and existing website?
Hi I am trying to use facebooker with an existing website that already has a model named ''User''. I therefore created a model called BkUser for use with facebooker. Also I have different controllers for all facebook requests. I am using acts_as_authenticated for handling login etc for my website and everytime a user is logged into my facebook app and tries to also browse the
2006 Apr 29
2
counter_caching clobbered when preloading association ?
Hi, I''m trying to use counter caching in a tree structure (in this case Bob Silva''s threaded list). This is the definition: class Folder < ActiveRecord::Base acts_as_threaded has_many :files end I would like each parent to have the total count of all the childrens member. So when inserting a new file I update the file_count following the parent_id through all the