Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.84 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. ## Model element.rb
  2. class Element < ActiveRecord::Base
  3. end
  4.  
  5. class Directory < Element
  6. end
  7.  
  8. ## Migration
  9.  
  10. class CreateElements < ActiveRecord::Migration
  11.   def self.up
  12.     create_table :elements do |t|
  13.       t.string :name
  14.       t.string :type
  15.       t.timestamps
  16.     end
  17.   end
  18.  
  19.   def self.down
  20.     drop_table :elements
  21.   end
  22. end
  23.  
  24. ## Console
  25. >> d=Directory.create(:name=>"test")
  26. NameError: uninitialized constant Directory
  27.         from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant'
  28.         from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
  29.         from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing'
  30.         from (irb):1