app/models/questionnaire.rb
def sections
    #self.questionnaire_parts.sort.map{|a| a.part}.reject{|a| !a.is_a?(Section)}
    q_ids = self.questionnaire_parts.find(:all, :conditions => {:part_type => "Section"})
    Section.find(q_ids.map(&:part_id), :joins => :questionnaire_part, :order => "questionnaire_parts.lft ASC", :include => [:questionnaire_part])
  end
#Returns an array with all the root sections, obtained through questionnaire parts.
Returns an array with all the root sections, obtained through questionnaire parts.
Returns an array with all the root sections obtained through questionnaire parts .
def sections
    q_ids = self.questionnaire_parts.find(:all, :conditions => {:part_type => "Section"})
    Section.find(q_ids.map(&:part_id), :joins => :questionnaire_part, :order => "questionnaire_parts.lft ASC", :include => [:questionnaire_part])
  end
def sections q_ids = self . questionnaire_parts . find ( :all , :conditions => { :part_type => "Section" } ) Section . find ( q_ids . map ( & :part_id ) , :joins => :questionnaire_part , :order => "questionnaire_parts.lft ASC" , :include => [ :questionnaire_part ] ) end
Returns an array with all the root sections, obtained through questionnaire parts.
Returns an array with all the root sections obtained through questionnaire parts .
#self.questionnaire_parts.sort.map{|a| a.part}.reject{|a| !a.is_a?(Section)}