If you have a construct like this (all in the same file):
# app/models/user.rb
class User < ActiveRecord::Base
# ...
end
class UnassignedUser < User
def self.shout
puts "yeah"
end
end
script/console will behave like this:
>> UnassignedUser.shout
NameError: uninitialized constant UnassignedUser (...)
>> User
=> User(id: integer, login: string, email: string, password: string,
created_at: datetime, updated_at: datetime)
>> UnassignedUser.shout
yeah
=> nil
UnassignedUser gets only loaded when User is loaded. put it in its own
file and maybe add:
self.abstract_class = true
other than that you can load it whenever you want via include or
require.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---