similar to: bug in has_many count?

Displaying 20 results from an estimated 700 matches similar to: "bug in has_many count?"

2005 Sep 10
4
has_too_many
Assuming you have Person that has_many :messages, what will it happen if it has 10000 messages? Will rails attempt to initialize @person.messages with 10000 rows from database? If that is the case, is combining finder_sql and counter_sql the common practice to avoid this? Bogdan _______________________________________________ Rails mailing list
2006 Feb 28
3
[AR] #{id} namespace visibility used in finder_sql
Dears, [Rails 1.0.0] I''m working with a legacy schema, and around my 20+ models i''ve used some AR constructs. They are based on a finder_sql doing some dirty sql and using #{id} from the ''pivot'' model for extracting data in other tables. like : class Division < ActiveRecord::Base set_table_name "legacy_division" set_primary_key
2006 Oct 30
2
It this possible: finder_sql-like behavior for belongs_to?
Guys, I have a need to support as has_many/belongs_to relationship on a legacy(kind of) schema. The reason I say kind of is that the schema does have "id" columns that are used in many associations, but this particular has_many/belongs_to association needs to support different ones. I''ve attached to code at the end of this email. Suffice it to say I need to use the standard
2005 Dec 27
3
Trouble combining :has_many, :finder_sql and :conditions to create a sub-search
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
2006 Mar 14
4
has_one
I''ve got an order model that stores order data. One piece of data is a credit card type, which is a digit 1,2 or 3. I have a cardType model that has an id, shortName and LongName for the credit card merchant (visa, mastercard, amex). I want to be able to say: order.cardType.shortName, but can''t seem to get has_one working. It works with has_many and a finder_sql statement on
2006 Jan 06
1
has_many with :finder_sql question
hi all, I have a Class, Client, which has_many projects (Project class). the projects depend on a session_id variable, however. So the question is, how can I do the following: has_many :projects, :finder_sql => "SELECT p.* FROM projects p INNER JOIN projects_users pu ON pu.project_id = p.id WHERE pu.user_id = #{session[:user_id]}" The problem is that I need to filter a
2006 Jan 17
15
legacy database and finder_sql nightmare!
This is my first rails app with a legacy database and I''m having a terrible time getting the models set up correctly. I have an order table that has a primary field named order_number. I have a name table with a primary of item_number. These two tables are liked by the item_number and the order_number, but not as you might think. If the order_number is 2500, then each entry in
2005 Dec 30
5
HABTM with finder_sql problem (Rails bug?)
I''m building an app that needs i18n support across the entire database (i.e. localized attributes). In order to do this I''ve created a special HABTM join table that can be associated with _any_ other table: create table language_strings ( for_table varchar(255) not null, foreign_id int not null, language_id varchar(5) not null, attr_name varchar(255) not null, value text
2006 Mar 10
4
problem when looping through habtm children in a view
I have this code in a view: <% for topic in @topics %> <%= topic.id %> <%= topic.dr_title %><br/> <ul> <% for doc in topic.child_documents %> <%= doc.dr_title %><br/> <% doc = nil %> <% end %> </ul> <% end %> Though the topic titles and IDs display correctly,
2006 Jan 18
3
legacy database on remote host
I''m getting this error in webrick then it crashes leaving nothing in the log. ruby: symbol lookup error: /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so: undefined symbol: mysql_sqlstate Here is the standard query I would normally write to get the data. select * from child,parent where CONCAT(SUBSTRING(child.item_number,1,14,''00'') = parent.order_number and
2008 Sep 25
1
defining polymorphic type condition
As great as Rails 2.1 is, I for the life of me cannot figure out why polymorphic associations do not support reconfiguring the type column used. For example, I have no way to do a polymorphic association using a lookup hash which maps an integer to a class name. Storing a TINYINT unsigned is waaaaay more efficient than storing a string like "SomeActiveRecordModel" over and over again.
2006 Aug 15
2
has_many + finder_sql & :include
Hello, In a model I have: has_many :things, :finder_sql => '' select * from other_things '' + '' where id = #{id} '' When I do MyClass.find(:all, :include => :things) I get a weird error: from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
2006 Aug 13
3
ruby and mysql syntax? tried single quotes, double, none, ...
Hi, how do i use passed in arguments and convert those to something sql can understand? do the aliases have to be double qouted? single qouted? i think i tried all but no avail...thanks! def get_count(doctype, towne) @profiles = Profile.count_by_sql("SELECT COUNT(*) from Profiles where Profiles.doctype_id = 1 and town_id = towne") end -- Posted via
2006 Jun 09
1
finder_sql issue with has_many :through
I have an inner join query that Action Record can''t seem to pull off conventionally, so I''m trying to use :finder_sql to utilize an sql query that works beautifully in SQL. The problem is, when I try to call the method, I get the following: private method `gsub'' called for #<Array:0x267de04> Here is my has_many code: has_many :mod_privileges,
2006 Jul 22
2
How to SELECT from multiple talbes with AR#find and associations?
So I want to SELECT from multiple tables, so as to be able to do "SELECT FROM foo, bar WHERE foo.id=bar.id AND bar.baz=23". How do I do it with AR#find? Also, I need this for associations. has_many et. al. have :finder_sql, which is nice, but feels like a Pyrrhic: it''s basically doing the association in pure SQL, defeating the purpose of AR. -- -Alder
2006 Feb 09
2
postgres connection problems
Hello, I''m a newbie to rails and I am trying to do the Demo in the November Issue of Linux Journal. Things go fine go fine until I try to connect to my Postgres database (ver 8.1). At this point I get the following error message ---- RoR error and trace back ---- PGError in Admin#index could not connect to server: Permission denied Is the server running on host "localhost"
2014 Apr 11
0
Replacement for "has_many ... counter_sql" in Rails 4.1
Hi I'm looking for ways to replace "has_many ... counter_sql: '...'" in order to migrate an app from Rails 3.2 to 4.0 (done) and then up to 4.1 which has dropped support for "counter_sql". An example is on Stackoverflow: http://stackoverflow.com/questions/22988321/replacement-for-has-many-counter-sql-in-rails-4-1 I'd do it with a separate counter method,
2007 Feb 08
3
Get categories where forum-user posted in
I''m developing a system similar to the ForumExample (http:// wiki.rubyonrails.org/rails/pages/ForumExample), and stumbled upon the following. Let''s say I wanted to get all the categories a certain user posted in. How do I get that information withouth using a custom query through :finder_sql (and thus losing the find_in_collection ownage)? It would also be great to see how many
2007 Mar 21
1
Eager Loading with custom :finder_sql
Is there any way to do eager loading when using custom :finder_sql ? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to
2007 Sep 06
1
finder_sql patch problem
Hello, I have the finder_sql problem and I found this patch http://dev.rubyonrails.org/ticket/7576; but I don''t know how to use this patch?? I copied all the changes into the correct files and restartet the server of my ruby on rails application, but nothing changed. Could someone tell me please how I have to use this patch?? Thanks Manfred