
Untitled
By: a guest on Jan 28th, 2012 | syntax:
None | size: 0.84 KB | hits: 6 | expires: Never
## Model element.rb
class Element < ActiveRecord::Base
end
class Directory < Element
end
## Migration
class CreateElements < ActiveRecord::Migration
def self.up
create_table :elements do |t|
t.string :name
t.string :type
t.timestamps
end
end
def self.down
drop_table :elements
end
end
## Console
>> d=Directory.create(:name=>"test")
NameError: uninitialized constant Directory
from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant'
from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from /Users/patakijv/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing'
from (irb):1