Skip to content

Instantly share code, notes, and snippets.

@jparbros
Last active December 23, 2015 00:09
Show Gist options
  • Select an option

  • Save jparbros/6551339 to your computer and use it in GitHub Desktop.

Select an option

Save jparbros/6551339 to your computer and use it in GitHub Desktop.
# views/surveys/_form.html.erb
<%= form_for @survey do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
# == Schema Info
#
# Table name: answers
#
# id :integer
# content :text
# created_at :datetime
# updated_at :datetime
#
class Answer < ActiveRecord::Base
belongs_to :question
end
# == Schema Info
#
# Table name: surveys
#
# id :integer
# content :text
# created_at :datetime
# updated_at :datetime
#
class Question < ActiveRecord::Base
belongs_to :survey
has_many :answers, :dependent => :destroy
end
# == Schema Info
#
# Table name: surveys
#
# id :integer
# name :string
# created_at :datetime
# updated_at :datetime
#
class Survey < ActiveRecord::Base
has_many :questions, :dependent => :destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment