similar to: has_many with :finder_sql question

Displaying 20 results from an estimated 2000 matches similar to: "has_many with :finder_sql question"

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 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 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 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
0
How do I combine :finder_sql and :conditions to perform a sub-search on a custom has_many relationship?
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 Jan 19
7
bug in has_many count?
I can submit a patch, but wanted to confirm I''m looking at this right... The docs indicate that if you specify a has_many association with :finder_sql, but no :counter_sql, it constructs the appropriate counter sql by substituting the SELECT clause. But has_many_association.rb doesn''t seem to do that -- it just passes Base#count_by_sql the finder_sql, which doesn''t
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all, My question is somewhat complicated, but bear with me. My project has a number of models: User, Program, and Team. Users belong to multiple Programs. Programs have multiple teams, but Teams belong to one program. For each Program a User belongs to, he can belong to multiple Teams. (Think of this in an athletic context where users are athletes, programs are universities). So my
2006 Jul 24
1
has_many + finder_sql
from the api I got: <pre> has_many :subscribers, :class_name => "Person", :finder_sql => ''SELECT DISTINCT people.* '' + ''FROM people p, post_subscriptions ps '' + ''WHERE ps.post_id = #{id} AND ps.person_id = p.id '' + ''ORDER BY p.first_name'' </pre> I would like to pass in the
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 Feb 13
0
has_many finder_sql #{id} single/double quotes voodoo
I never would have figured this out in many moons: has_many :subscribers, :class_name => "Person", :finder_sql => ''SELECT DISTINCT people.* '' + ''FROM people p, post_subscriptions ps '' + ''WHERE ps.post_id = #{id} AND ps.person_id = p.id '' + ''ORDER BY p.first_name'' Variable
2011 Sep 27
0
has_many with :finder_sql returns [nil]?
Is it supposed to do that? I find it very confusing. AR 3.0.10 class Unit has_many :units, :finder_sql => proc { "SELECT * FROM `#{table_name}` WHERE `location_id`=#{id} AND `location_type`=#{Location::UNIT}" } end Both should return []. However... >> Unit.first.units.find([1000000]) [2011-09-27 10:05:11|main|debug] Unit Load (4.0ms) SELECT `units`.* FROM `units`
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
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
2006 Aug 13
1
Is :finder_sql using #{id} broken?
Hi All, It seems that :finder_sql in a HABTM association only interprets a single quoted #{id} the first time through a query. I see examples of this being used in a few places (though with has_many) and I don''t really see how to use :finder_sql without a #{id}. Am I missing something or is this just broken? -- Paul Haddad (paul.haddad@gmail.com paul@pth.com)
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
2005 Feb 24
2
other than default labels in lattice plot
Dear all I solved a problem of customised labels on strips and boxes in bwplot by this construction. > bbb <- bwplot(zavoj ~ typmleti | pu) > bbb$condlevels$pu <- c("Povrchov? ?prava", "Bez PU") > bbb$x.limits <- c("Mleto", "Mleto a s?tov?no", "Nemleto") > bbb but I wonder if some other easy option exist. Let say something
2014 Dec 05
2
Inbound call from sip peer to internal webrtc peer fails while internal sip-webrtc calls work
Hello, I'd appreciate your comments on the following problem I'm having, please forgive me if this is something obvious, I've been scratching my head on this for a while: I have Asterisk+Kamailio setup where I'm currently testing inbound calls from outside. I have both webrtc and sip clients, where webrtc peers are defined according to sip.js instructions (
2014 Sep 08
1
Asterisk removes ice lines in sdp when calling between webrtc clients
Hello, I have a problem with a call between 2 webrtc clients. Asterisk removes the ice-related lines from the sdp when it sends the INVITE out, and the called webrtc client rejects the INVITE due to the missing ice lines. Both webrtc clients are defined exactly the same way, same values in all fields except the number of the peer. There's probably something I've changed that causes this