For example:
Environment: Ruby 1.9.2 Rails 3.0.5 Mongoid
I have a Survey model and embeds many Questions in it. Now I want to define a function "publish" in surveys_controller.rb:
def publish
@survey = Survey.find(params[:id])
@questions = Survey.questions
... how to build a model? ...
@questions.each do |question|
... and then how to add fields (named with question.title) and define type (named with question.type) ...
end
end```