search for: construct_sql

Displaying 11 results from an estimated 11 matches for "construct_sql".

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
2006 Mar 15
4
help with DRY violation
...for Table A using various callbacks, after_create, after_save, before_create. Trying to set the table_b attribute to a new Table B instance and have table_b''s foreign key be the id the table_a object being created. However, i kept running into exceptions "undefined method ''construct_sql''. I checked my dev log and saw there was an INSERT query for table_b just after table_a''s INSERT, which is what i wanted. But it dies right after. Why is that? So do i need to just call table_a_inst.table_b = Table_B.new() table_a_inst.save everytime i want to create a Table_A...
2007 May 24
3
Annoying problem, stack error
...ve_record/reflection.rb:125:in `send'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/reflection.rb:125:in `klass'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_association.rb:194:in `construct_sql'' ... 30 levels... from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:154:in `parse'' from /Users/sparta/Projects/work/idastudios/ff/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:88:in `create_behavio...
2006 Feb 23
3
has_many reference
...s/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1198:in `id'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1209:in `quoted_id'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations/has_many_association.rb:169:in `construct_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations/has_many_association.rb:8:in `initialize'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:753:in `new'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.1...
2006 Jul 31
3
Polymorphic associations and single table inheritance
...mber < Person end Adding an Address to a Member results in the addressable_type column equaling "Person" when it should be "Member". Looking in ActiveRecord::Associations::AssociationProxy#set_belongs_to_association_for and ActiveRecord::Associations:: HasManyAssociation#construct_sql it''s clear why. >From ActiveRecord::Associations::AssociationProxy#set_belongs_to_association_for: record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s Removing the call to base_class results in the behavior I expected. I did this by patching th...
2005 Oct 25
1
initialising an instance variable on ActiveRecord creation
...ble_stack=PropertyVariableStack.new end When this ran, I could trace all the correct SQL being generated in the logs, but it raised an error: test_sample(TestPropertyLoader) [Z:/sics/test/tc_property_loader.rb:66]: Exception raised: Class: <NoMethodError> Message: <"undefined method `construct_sql'' for #<PropertyVariableStack:0x2c77d0 8>"> Can anyone tell me why this is? & maybe advise on how to achieve what I''m after? Thanks in advance, doug.
2008 Sep 25
1
defining polymorphic type condition
...orphic 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. Looking in the association proxy classes for has_one and has_many, I see: def construct_sql case when @reflection.options[:as] @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " + "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_...
2008 Nov 03
0
acts_as_rateable in rails 2.2.0
.../activerecord-2.2.0/lib/active_record/reflection.rb:151:in `klass'' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:182:in `quoted_table_name'' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/has_many_association.rb:91:in `construct_sql'' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:21:in `initialize'' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations.rb:1289:in `new'' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.0/lib/ac...
2007 May 30
2
ActionView::TemplateError
...LS_ROOT}/vendor/rails/activerecord/lib/active_record/ reflection.rb:125:in `send'' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/ reflection.rb:125:in `klass'' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/ associations/has_many_association.rb:174:in `construct_sql'' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/ associations/has_many_association.rb:6:in `initialize'' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/ associations.rb:998:in `new'' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record...
2006 Feb 26
4
Creating objects with has_many :through relationship
Three tables: users: id clients: id admin_contacts: user_id, client_id class Client has_many :admin_contacts has_many :contacts, :through => :admin_contacts, :foreign_key => :user_id, :class_name => ''User'' end I added the :contacts for ease of use of grabbing the user objects associated with the admin_contact. This all works great, I can grab the Users that
2008 May 16
0
attachment_fu and/or rmagick on osx -- weird error
...e/framework/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/reflection.rb:129:in `table_name'' /Applications/Locomotive2/Bundles/rmagickRailsMar2007_i386.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:67:in `construct_sql'' /Applications/Locomotive2/Bundles/rmagickRailsMar2007_i386.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_one_association.rb:6:in `initialize'' /Applications/Locomotive2/Bundles/rmagickRailsMar2007_i386.locobundle/framework/lib/r...