Hi all,
I have some issues in Rails Active Record Inheritance, I need to create a model that inherits parents class properties(fields) and should also hold its own properties.
Ex: Parent Class
class Content < ActiveRecord::Base
end
Classes inheriting parent class (Content)
class Wiki < Content // Inherting Class Content
end
class Video < Content // Inherting Class Content
end
Suppose "content" table contains fields type,name (to store common fields)
- "Wiki" table contains fields body,description
- "Video" table contains fields filename,description
Inserting into content and wiki table as
def create
WikiPage.new("name" =>"new_wikipage")
@wiki_page = WikiPage.new(params[:wiki_page])
end
but, the problem is the newly created wikipage is not inserting(because the parent class "Content" is abstracting child class Wikipage param values)
Generating Error like method "body" not defined (field "body" is part of wiki table,which got hided by content table)
Can any one explain,How to solve this
regards, Mahesh