Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Last active August 24, 2017 16:47
Show Gist options
  • Save staycreativedesign/058e2cfb0787b584db5b885d04a81d6d to your computer and use it in GitHub Desktop.
Save staycreativedesign/058e2cfb0787b584db5b885d04a81d6d to your computer and use it in GitHub Desktop.
answer text_fields are not showing up
class Questionnaire < ApplicationRecord
has_many :questions
has_many :member_questionnaires
has_many :users, through: :member_questionnaires
accepts_nested_attributes_for :questions
end
class Question < ApplicationRecord
belongs_to :questionnaire
has_one :answer
accepts_nested_attributes_for :answer
end
class Answer < ApplicationRecord
belongs_to :question
end
https://www.youtube.com/watch?v=WxqmaKk79Hw
%h1
questionnaires#edit
= form_for @questionnaire do |f|
- @questionnaire.questions.each do |q|
%h1
= q.description
- f.fields_for :question, q do |question_fields|
%h1
not showing up
- question_fields.fields_for :answer, q.build_answer do |answer_fields|
%h1
not showing up 2
= answer_fields.text_field :description
= f.submit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment