Last active
August 29, 2015 14:09
-
-
Save rShetty/03e0693ef41544360de3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composed_of :amount, | |
:class_name => 'Money', | |
:mapping => [%w(amount value), %w(currency_id currency_id)], | |
:constructor => Proc.new { |amount, currency_id| Money.new(amount, currency_id) } | |
class Money | |
attr_reader :value, currency_id | |
def initialize(value, currency_id) | |
@value = value | |
@currency_id = currency_id | |
end | |
end | |
Error : NoMethodError: undefined method `value' for 80:Fixnum | |
t = Transaction.create!(amount: 100, currency: Currency.last, wallet: Wallet.last, description: "A", direction: 'Cr') | |
Currency Load (0.4ms) SELECT `currencies`.* FROM `currencies` ORDER BY `currencies`.`id` DESC LIMIT 1 | |
Wallet Load (0.3ms) SELECT `wallets`.* FROM `wallets` ORDER BY `wallets`.`id` DESC LIMIT 1 | |
NoMethodError: undefined method `value' for 100:Fixnum | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/aggregations.rb:255:in `block (2 levels) in writer_method' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/aggregations.rb:255:in `each' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/aggregations.rb:255:in `block in writer_method' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/attribute_assignment.rb:45:in `public_send' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/attribute_assignment.rb:67:in `block in assign_attributes' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/attribute_assignment.rb:61:in `each' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/attribute_assignment.rb:61:in `assign_attributes' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/core.rb:8:in `init_attributes' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/core.rb:198:in `initialize' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/inheritance.rb:30:in `new' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/activerecord-4.1.5/lib/active_record/inheritance.rb:30:in `new' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/validations.rb:15:in `create!' | |
from (irb):9 | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/railties-4.1.5/lib/rails/commands/console.rb:90:in `start' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/railties-4.1.5/lib/rails/commands/console.rb:9:in `start' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:69:in `console' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!' | |
from /Users/rajeevnb/.rvm/gems/ruby-2.1.1@eWallet/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>' | |
from bin/rails:4:in `require' | |
from bin/rails:4:in `<main>'>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment