Last active
December 14, 2015 10:29
-
-
Save wallace/5072249 to your computer and use it in GitHub Desktop.
Override a Rails attr_accessor method with a method that expects an argument and watch it fail.
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
temp.rb:19:in `title': wrong number of arguments (0 for 1) (ArgumentError) | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activemodel-3.2.12/lib/active_model/dirty.rb:143:in `attribute_change' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activemodel-3.2.12/lib/active_model/dirty.rb:117:in `block in changes' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activemodel-3.2.12/lib/active_model/dirty.rb:117:in `map' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activemodel-3.2.12/lib/active_model/dirty.rb:117:in `changes' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:34:in `block in save!' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:33:in `tap' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:33:in `save!' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/transactions.rb:264:in `block in save!' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/transactions.rb:311:in `with_transaction_returning_status' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.12/lib/active_record/transactions.rb:264:in `save!' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/configuration.rb:18:in `block in initialize' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/evaluation.rb:15:in `[]' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/evaluation.rb:15:in `create' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/strategy/create.rb:12:in `block in result' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/strategy/create.rb:9:in `tap' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/strategy/create.rb:9:in `result' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/factory.rb:42:in `run' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/factory_runner.rb:23:in `block in run' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.12/lib/active_support/notifications.rb:125:in `instrument' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/factory_runner.rb:22:in `run' | |
from /Users/jonathanwallace/.rvm/gems/ruby-1.9.3-p125/gems/factory_girl-3.4.2/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method' | |
from temp.rb:29:in `<main>' |
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
require 'rubygems' | |
require 'factory_girl' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
adapter: "sqlite3", | |
dbfile: ":memory:", | |
database: "temp" | |
) | |
ActiveRecord::Schema.define do | |
create_table :albums do |table| | |
table.column :title, :string | |
table.column :performer, :string | |
end | |
end | |
class Album < ActiveRecord::Base | |
def title(asdf) | |
end | |
end | |
FactoryGirl.define do | |
factory :album do | |
title "title" | |
end | |
end | |
album = FactoryGirl.create(:album) | |
p album.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment