Skip to content

Make the first field appear by default

Ivan Raszl edited this page Jun 11, 2019 · 7 revisions

By default the gem doesn't show a field to the user. It shows a button, which the user has to click: (ex. 'Add Task') to make the field to appear.

If you want an initial field to appear by default, you need to create an object for the child (ex. 'Task') in the parent controller (ex. 'Project'):

Example controller action:

def new
  @project = Project.new
  @project.tasks.build
end

Nothing needs to be changed in the form or partial.