Hi, all. I'm wrestling with subclassing models in AR. Wondering if i'm
running up against a limitation on sub-subclassing, or if the syntax
has gone awry here.

My app has BlogPosts, which are a sub of Articles. It's got Writers <
RegisteredUsers < Users.

When I try to call registered_user on a BlogPost, I get nil.

Any & all help appreciated.


class Article < ActiveRecord::Base
  etc....

end

class BlogPost < Article
  validates_presence_of :section_id, :title, :body
  belongs_to :registered_user

end

class NewsArticle < Article
 belongs_to :writer
end


require "digest/md5"
class User < ActiveRecord::Base
 etc...
end

class RegisteredUser < User
   validates_uniqueness_of :name
   has_many :comments
   has_many :events,  :class_name => "Article", :foreign_key =>
"user_id"
   has_many :blog_posts, :class_name => "Article", :foreign_key =>
"user_id"
end

class Writer < RegisteredUser
  has_many :news_articles, :class_name => "Article", :foreign_key =>
"user_id"
end


>> @post=BlogPost.find(:first, :conditions=>'user_id=1')
=> #<BlogPost id: 505, title: "Cubs outlook", type: "BlogPost",
user_id: 1>
>> User.find(1)
=> #<Writer id: 1, type: "Writer">
>> @post.registered_user
=> nil
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to