Skip to content

Instantly share code, notes, and snippets.

@ogryzek
Last active August 29, 2015 13:56
Show Gist options
  • Save ogryzek/9257104 to your computer and use it in GitHub Desktop.
Save ogryzek/9257104 to your computer and use it in GitHub Desktop.
accepts_nested_attributes
%fieldset.answer
= f.label :title
= f.text_field :title
= f.label :body
= f.text_field :body
= f.check_box :_destroy
= f.label :_destroy
%br
= form_for(@question) do |f|
- if @question.errors.any?
#error_explanation
%h2
= pluralize(@question.errors.count, "error")
prohibited this question from being saved:
%ul
- @question.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :title
%br
= f.text_field :title
.field
= f.label :body
%br
= f.text_area :body
%h3 Options
= f.fields_for :options do |opt|
= render "option_fields", f: opt
= link_to_add_fields "Add Option", f, :options
%br
= f.submit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment