similar to: Aggregation: problem with uninitialized composed_of object

Displaying 20 results from an estimated 3000 matches similar to: "Aggregation: problem with uninitialized composed_of object"

2005 Dec 17
1
How to use validation with aggregation (composed_of)?
At the risk of being banned for posting the same question twice, I thought I''d try once more with a question for the title rather than a statement (on the basis that perhaps questions get answered and statements ignored ;-) ) ActiveRecord supports composed_of for value objects which is fantastic but one thing that it doesn''t seem to support (or at least I am unable to
2007 Nov 13
4
question about activerecord test_numeric_fields in base_test.rb
There''s a test for activerecord called test_numeric_fields in base_test.rb. here''s the test def test_numeric_fields m = NumericData.new( :bank_balance => 1586.43, :big_bank_balance => BigDecimal("1000234000567.95"), :world_population => 6000000000, :my_house_population => 3 ) assert m.save m1 =
2009 Feb 26
1
composed_of, aggregate object isn't saved
I am relatively new to rails and I cannot figure out what is going on here. I am using the composed_of method in an ActiveRecord class to create two aggregate properties: shipping_address and billing_address. The object properties are getting populated from the form and validation is working - no problem. When I call order.save, though, everything is being saved except the address fields. I am not
2009 Feb 03
4
Ruby EE: Problem with BigDecimal
I have a strange problem with my setup of Passenger and Ruby Enterprise Edition. Sometimes the loading of BigDecimals from the database and session fails (silently) and the variable containing the BigDecimal is just empty. I cannot pinpoint where/when/how it happens, and it IS only periodic. I am using the newest versions of both Passenger and REE - I have even tried to run with latest commit
2012 Feb 29
1
can't convert Fixnum into String in relativity
good day i read about relativity gem but when i try to use it and make a test file and build it gives me an error =test.rb= <pre> require ''relativity'' opens_at = DayTime.new(9) #=> 09:00:00 closes_at = DayTime.new(12,30) #=> 12:30:00 </pre> <pre> /home/start/.rvm/gems/ruby-1.9.2-p290/gems/relativity-0.0.8/lib/ relativity/day_time/new.rb:24:in
2006 Mar 31
6
BigDecimal + Float => Float?
I was just playing around in irb and noticed that while BigDecimal + Integer => BigDecimal, BigDecimal + Float => Float. Is there any reason for this? It seems inconsistent and means you have to check the class of any number you add to a BigDecimal, which looks very un-Ruby-like to me. Ashley
2006 Jul 13
1
Incorrect composed_of I think
I am trying to use composed_of in my model, but I not succeeding. With the code I pasted below, I cannot perform this action in the console: property = Property.new(1, "px") I get NameError: uninitialized constant Property when I try to perform that action. It''s not finding my class I made I suppose. The Property class is in the same file as the Element class, element.rb.
2006 Jul 11
1
Validating composed_of
Hi, How do I validate a composed_of attribute in my model? I have a product model with: composed_of :price, :class_name => ''Money'', :mapping => %w(cents cents) This maps the price attribute to the Money (http://dist.leetsoft.com/api/money/) class. I want to make sure that the price only contains a price to 2 decimal places i.e. 1.25. This is because if someone enters
2006 Jul 23
0
composed_of and validates_presence_of
I''m using composed_of in one of my models, and I''d like to validate that the attribute is present. class Hand < AR::Base composed_of :level, :mapping => [ %w(sb sb), %w(bb bb), %w(ante ante) ] validates_presence_of :level, :message => "must be set" end The Level class itself is very simple: class Level include Reloadable attr_reader :sb, :bb, :ante
2005 Dec 16
4
Validation with Aggregation
ActiveRecord supports composed_of for value objects which is fantastic but one thing that it doesn''t seem to support (or at least I am unable to find any documentation for) validation of the value objects. For example, given the following: class Message < ActiveRecord::Base composed_of :sender, :class_name => ''EmailAddress'' composed_of :recipient,
2008 Jun 11
1
Resourse route in namespace with prefix error
Ok so I have this route map.namespace :trades do |trades| trades.resources :buys, :path_prefix => ''/trades/:contract_id'' end I want the contract_id variable to filter a list of buys then I try to open this route http://localhost:3000/trades/1/buys I get a strange error: ActionController::RoutingError in Trades/buys#index Showing trades/buys/index.html.erb where line
2008 Jan 19
1
Decimals are being converted to Bigdecimals!!!!!
Hi all, I''m working on a financial app, and have set up some columns in my tables as decimals with precision => 8 and scale => 2. My migration looks like: change_column :lineitems, :price, :decimal, :precision => 8, :scale => 2 change_column :payments, :amount, :decimal, :precision => 8, :scale => 2 I''ve run the migration and restarted the server. I
2006 Mar 19
4
Trouble with composed_of
I''m trying to use composed_of within my model. I have a field in my database named ''card1'', which is simply a string. I have this in my model class Player < ActiveRecord::Base composed_of :card1, :class_name => ''Card'' end class Card attr_reader :value, :suit def initialize(s) @value = s[0].chr @suit = s[1].chr end end The
2009 Oct 07
1
output validations errors form causing type error?
Hi, I was wondering if it is possible to output validation errors in a nested form? I suppose this should be possible, but I am experiencing an error message that I can''t track down. The error I get is the following : TypeError in Store/orders#create Showing app/views/store/orders/new.html.erb where line #45 raised: can''t convert Array into String This is ocurring in the
2009 Nov 18
2
Composing Data from THREE models with Aggregation
Hello! I''m looking for assistance EXTENDING an example from the Agile Web Development With Rails book: Composing Data with Aggregation (page 324). I''m trying to map three columns to a single Ruby object. However, unlike the example in the Agile Web Development book, the three columns I want to map into one object come from THREE DIFFERENT models. I want to map the following
2006 Mar 03
0
unused composed_of bits
I implemented a Temperature model for my application. It is pretty basic, composed of a temperature, a unit and some conversion methods. In my app model I decided to store temperature values in Fahrenheit, so there is no need to remember the units between invocations. I am having a little trouble composing my app model. A little bit of my temperature class: class Temperature # Composed of
2006 Jan 22
0
Validation on composed_of problem
I am having problems with this: validates_presence_of :amount validates_format_of :amount, :with => Money::PATTERN, :allow_nil => true composed_of :amount, :class_name => Money, :mapping => [[:amount, :to_s]] The problem is when I use this field in a form, and the text is blank, ActiveRecord gives me two errors: "money is invalid" "money
2010 Jul 08
3
Testing equality
Hello How can I test equality with two objects when they include some attribute that is BigDecimal? if I make something like this: it "should ...whatever" do obj = Factory.create(:my_object) ... MyObject.first.should == obj end. FAILS This fails because the object expected is different from the object gotten, and the only difference are the BigDecimal attributes, that are
2006 Jul 22
3
refactoring commonly used aggregations
I have a number of models that use an aggregation to combine First Name, Middle Initial and Last Name and they have been working fine. I am looking to clean this up, DRY it if possible. I have things like this in application.rb class Clwholename attr_reader :first_name, :middle_initial, :last_name def initialize(first_name, middle_initial, last_name) @first_name = first_name
2006 Jul 09
6
Float -> BigDecimal
So, I''m personally cool with this change (patch from #5454, applied in [4596]), and I''ll make it work for Oracle tomorrow. But just wondering if folks considered the performance impact of the change? From a simple test it seems that BigDecimal math is about twice as slow as using Floats.