Skip to content

Instantly share code, notes, and snippets.

@deathbob
Created January 14, 2011 20:39
Show Gist options
  • Select an option

  • Save deathbob/780186 to your computer and use it in GitHub Desktop.

Select an option

Save deathbob/780186 to your computer and use it in GitHub Desktop.
master>rails new yammy
[... nothing to see here ...]
master>cd yammy
master>rails g model Dummy name:string
invoke active_record
create db/migrate/20110114203601_create_dummies.rb
create app/models/dummy.rb
invoke test_unit
create test/unit/dummy_test.rb
create test/fixtures/dummies.yml
master>rake db:create
(in /Users/bob/src/yammy)
master>rake db:migrate
(in /Users/bob/src/yammy)
== CreateDummies: migrating ==================================================
-- create_table(:dummies)
-> 0.0013s
== CreateDummies: migrated (0.0014s) =========================================
master>rails console
Loading development environment (Rails 3.0.3)
no such file to load -- wirble
ruby-1.8.7-p302 > d= Dummy.new
=> #<Dummy id: nil, name: nil, created_at: nil, updated_at: nil>
ruby-1.8.7-p302 > d.name = "Todd"
=> "Todd"
ruby-1.8.7-p302 > d.save
=> true
ruby-1.8.7-p302 > d
=> #<Dummy id: 1, name: "Todd", created_at: "2011-01-14 20:36:31", updated_at: "2011-01-14 20:36:31">
ruby-1.8.7-p302 > tom = d.to_yaml
=> "--- !ruby/object:Dummy \nattributes: \n name: Todd\n created_at: &id001 2011-01-14 20:36:31.606010 Z\n updated_at: *id001\n id: 1\nattributes_cache: \n created_at: *id001\n updated_at: *id001\nchanged_attributes: {}\n\ndestroyed: false\nerrors: !omap []\n\nmarked_for_destruction: false\npersisted: true\npreviously_changed: !map:ActiveSupport::HashWithIndifferentAccess \n name: \n - \n - Todd\n created_at: \n - \n - *id001\n updated_at: \n - \n - *id001\n id: \n - \n - 1\nreadonly: false\nvalidation_context: \n"
ruby-1.8.7-p302 > YAML.load(tom)
NoMethodError: undefined method `keys' for nil:NilClass
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.3/lib/active_record/base.rb:1512:in `attribute_names'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.3/lib/active_record/base.rb:1569:in `attributes'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:57:in `attribute_method?'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:394:in `match_attribute_method?'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:393:in `each'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:393:in `match_attribute_method?'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:378:in `respond_to?'
from /Users/bob/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:52:in `respond_to?'
from /Users/bob/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/yaml.rb:133:in `transfer'
from /Users/bob/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/yaml.rb:133:in `node_import'
from /Users/bob/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/yaml.rb:133:in `load'
from /Users/bob/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/yaml.rb:133:in `load'
from (irb):6
ruby-1.8.7-p302 > Rails.version
=> "3.0.3"
ruby-1.8.7-p302 > Rails.env
=> "development"
ruby-1.8.7-p302 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment