Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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 %>
Add Comment
Please, Sign In to add comment