similar to: Association count caching

Displaying 20 results from an estimated 70000 matches similar to: "Association count caching"

2006 Jan 02
3
Altering the accessor of an association collection
I want to be able to do something like this (for example): class Person < ActiveRecord::Base has_many :friends def friends(living_in = :uk) # filter based on parameters here end end Is there any way I can redefine the accessor for an association whilst still being able to get the values? Basically, I''m looking for an equivilent of read_attribute() for associations. --
2006 Jan 29
11
HTML Output plugin
I have written a very small Rails plugin which makes it spit HTML back at you instead of XHTML. Find details here: http://dev.turnipspatch.com/trac/wiki/HTMLOutput Hope it''s useful to someone! Jon -- Posted via http://www.ruby-forum.com/.
2013 Jul 16
0
Which object have my association extension method?
My Stackoverflow question: http://stackoverflow.com/questions/17461273/where-does-association-extension-sit-in/17664817?noredirect=1#17664817 I have an association extension method like the following: class Bundle < ActiveRecord::Base has_many :items do def foo end end I was trying to use delayed job/sidekiq delay() method like the following: b.items.delay.foo But I
2006 May 05
0
Missing documentation for find_in_collection? Trying to drill down in a 4 level has_many association fails
I''ve been reading up in ActiveRecord::Associations and playing around with my app via the console and found some interesting methods via the code completion of IRB, but I have no idea how to use them and can only find one hint in the API http://api.rubyonrails.com/classes/ActiveRecord/Associations/ ClassMethods.html It mentions here in the has many associations that if you use the
2008 Mar 07
1
Error: file association for 'doc\html\index.html' not available or invalid
Today HTML help stopped working. The menu command "Help > Html help" usually brings up my default web browser (Opera 9.26), but now R gives the error Error: file association for 'doc\html\index.html' not available or invalid If I try the same menu command a second time, R crashes with the message The instruction at "0x7c9106c3" referenced memory at
1999 Jun 26
0
Password caching and smbsh
First off, I don't know if this is password caching revisited with a vengeance or what. It's very inconsistent for the amount of time the share will stay mounted. I *think* the following are the relevant messagess in the log: Jun 23 22:24:36 reliant kernel: smb_trans2_request: result=-32, setting invalid Jun 23 22:24:36 reliant kernel: smb_retry: caught signal And of course, I get the
2006 Apr 29
1
Caching foor starters
Hi there... I have some experience in building web applications but all of them have been intranet apps so I have never had to think about things like caching. Actually my experience with caching has more been in the area of removing it since it just gets in the way for a intranet app with 10-100 users. But now I am writing a site which might stand or fall by the quality of it''s
2006 Jun 26
0
Action caching with params
I was attempting to cache an action that had a URL like this: http://foo.com/controller/action?years[]=2005&years[]=2006&bar=5&baz=blue which returns different data than, say http://foo.com/controller/action?years[]=2004&years[]=2005&bar=6&baz=red However, the cached fragment would always be named foo.com:3000/controller/action.cache, no matter what parameters where
2004 Jul 12
2
Association between discrete and continuous variable
What's the reommended way, in R, to determine the strength of association between a discrete variable and a continuous variable? Yes, I have read the manuals, trawled the archives, &c.
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
2006 Jun 07
1
Calling find on AR class, order by association count?
I suspect that this is going to wind up trivial and I''m going to slap myself in the head... Suppose I have User and Comment AR classes. User has_many :comments, Comment belongs_to :user I want to do a User.find, which returns User objects in order of which user has the most comments. I suspect that this involves renaming the COUNT(*) results of a sub-select so that I can order by
2010 Nov 24
0
Surprise in (delete_all | clear | destroy_all) on association
Hi, I was very surprised by difference of delete_all on association vs model(delegated to relation). Given TaskFilter.has_many(:qualifiers, :class_name=>''TaskFilterQualifier'') TaskFilter.delete_all => one DELETE statement Without :dependent option on "qualifiers" association TaskFilter.first.qualifiers.delete_all => SELECT `task_filter_qualifiers`.* FROM
2008 May 08
1
Eager loading of association extensions
Hello all, Is it possible to do eager loading of association extensions? That is, the following code produces one SQL query: cat = ProductCategory.find(:first, :include => :pricing_rules) cat.pricing_rules But if in ProductCategory I have an association extension like this: has_many :pricing_rules do def applicable() find(:all).select(&:applicable?) end end the
2006 May 08
2
Creating a "Foo has_many bars" association where bar isn''t a model.
Hi Let''s say we have model Foo. Each Foo instance can have several bars. Those bars are primitive, so they shouldn''t be models. For example, Foo might be a type of convention, and the bars might be years the convention was held in. Naively, we would have a conventions_years date, and put: has_many :years inside class Convention. But then we''d get an error, since for
2007 Feb 06
2
Login systems : stubbing accounts and AR association proxies
My Rails site has a fair amount of login and ''ownership'' logic. For instance, we have a number of clients (companies), each of which has several accounts. A client owns a number of different types of resources, and shouldn''t see any other clients'' resources, so, for example, our ScenesController contains a lot of references to
2006 Apr 06
0
Association extensions: how to access the object?
With association extensions, like user.items.tagged("foo"), how do I access the "user" object from within the extension method? The code would be e.g. class User < ActiveRecord::Base has_and_belongs_to_many :items do def tagged(tag) return "These are items tagged %s from user %s." % [tag, ???] end end but how would I get a hold of
2011 Apr 16
0
adding HABTM association while creating a record
Hello Experts, I have a HABTM association as followed: class Account < ActiveRecord::Base has_and_belongs_to_many :user end class User < ActiveRecord::Base has_and_belongs_to_many :type has_and_belongs_to_many :account end class Type < ActiveRecord::Base has_and_belongs_to_many :user end I have the following query; I Have a parent user who is creating another user under its
2006 Jul 24
3
HowTo?: Eager caching of third order ActiveRecord assoc.
Hello. Using the ":include", which generates a "LEFT OUTER JOIN" SQL command, it is possible to eagerly preload second order data objects (children) for a given association. I wanted to know, if it is possible to eagerly preload and cache third order (or more) data objects, which are little-children or little-little-children. As I''ve seen. it is possible to add
2009 Feb 15
3
conditions on association include, hacky but more or less solved
Hi all, I just finally figured out how to get 2.2.2 to do this, and thought I''d share in case others run into the same thing. The situation is a find with associations, but the tricky part is that the association shouldn''t always be loaded. This is similar to putting a condition on a has_many association in a model, but the condition is dynamic rather than predefined. The
2008 Sep 23
3
Association error using find since upgrading to Rails 2.1.1
Hi all, Ruby 1.8.6 Rails 2.1.1 I have a simple association that works fine under 1.2.6 but is failing under 2.1.1. require ''active_record'' ActiveRecord::Base.establish_connection( :adapter => ''postgresql'', :database => ''my_database, :username => ''postgres'' ) class Schedule < ActiveRecord::Base belongs_to