Displaying 3 results from an estimated 3 matches for "reflect_on_aggregation".
2006 Mar 09
1
[TIP] Making an intelligent form fields
...request.
So I used reflection on aggregation and as attributes are about to be
processed, they are "objectized", so attributes[:i_discount_rate] will
gain a real Percentage object:
def attributes=(attributes)
attributes.each do |param, value|
aggregation = self.class.reflect_on_aggregation(param.to_sym)
if aggregation
attributes[param] = aggregation.klass.new(value)
end
end
super(attributes)
end
Now an user can enter "2%", "2.0 %", "2.1 % ", etc. and everything is
acceptable. We can now create value object f...
2006 Sep 26
0
Bug or Feature?
...rowing that exception there is the intended feature.
That bit of code could possibly be rewritten as (completely un tested):
------------------
def execute_callstack_for_multiparameter_attributes(callstack)
errors = []
callstack.each do |name, values|
klass = (self.class.reflect_on_aggregation(name.to_sym) ||
column_for_attribute(name)).klass
if values.empty?
send(name + "=", nil)
else
begin
send(name + "=", Time == klass ? klass.local(*values) :
klass.new(*values))
rescue => ex
sen...
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde