Skip to content

Best way to set drafts for child attributes? #7

@kibaekr

Description

@kibaekr

Let's say you have an Article, and inside an article you have many Steps (think of a how-to wikihow article)

I was able to make a draft for the article, but I can't do something like "Article.first.draft.steps"

What would be the best way to set up the draft associations for the parent and children models? Would I need to create a Step::Draft table as well?

I did this

 #Article.rb model 
 has_draft do 
   has_many :step_drafts, order: 'position ASC'
   accepts_nested_attributes_for :step_drafts, allow_destroy: true
 end

and tried creating a draft of the step:

   Article.first.draft.step_drafts.new 

but get this error

  NameError: uninitialized constant Article::Draft::StepDraft

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions