Displaying 2 results from an estimated 2 matches for "order_value".
2007 May 23
10
Modifying Conditions for has_many at runtime in controller?
...show
only the People/Orders where the Order''s value is greater than $100"
When the user sets this criteria on a web form, I now need to modify
my has_many association. I now need the association to be:
class Person < ActiveRecord::Base
has_many :orders, :conditions => "ORDER_VALUE > 100"
end
This way, when I do a person.orders.count, I should only get the count
of orders where the Order Value is greater than $100.
Is there any way I can do what I''m describing here? I''m open to any/
all possibilities here.
Thanks for your help! I''m ver...
2006 Jul 20
0
Refactoring common code to module
...share some common funcionality that only differs by name of the
associations.
module GACL
class AclSection < ActiveRecord::Base
set_table_name "gacl_acl_sections"
has_many :acls, :dependent => true
validates_presence_of :name, :value
validates_numericality_of :order_value
validates_uniqueness_of :value
def instance_method_for_acl (would be the same functionality for the
others, too)
...
acls.each do |acl|
...
end
end
end
end
Is it possible to do some refactoring, so I only have to define my code
once and the method names get u...