Created
October 27, 2009 19:17
-
-
Save lorennorman/219855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# STI Models | |
class Question < AR::Base; end # should never be instantiated | |
class YesNoQuestion < Question; end # should | |
class TextQuestion < Question; end # should | |
# etc... | |
# Form.rb (model) | |
accepts_nested_attributes_for :questions # except I don't want to instantiate Question! | |
# forms/edit.html.erb (view) | |
...normal form_for |f|... | |
<% f.fields_for :questions do |question_form| %> | |
<%= question_form.select :type, { "Yes/No" => "YesNoQuestion", "Text" => "TextQuestion" } %> | |
<% end %> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment