Skip to content

Commit

Permalink
Carlos/Pedro/Rafael/Daniel - rapidftr#90 - default ordering on new ch…
Browse files Browse the repository at this point in the history
…ild record form (in FormSection.all)
  • Loading branch information
ThoughtWorks Brasil RHoK Team authored and Tom Elkin committed Jul 6, 2010
1 parent 73ea94b commit 48287ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/form_section_controller.rb
@@ -1,6 +1,6 @@
class FormSectionController < ApplicationController
def index
@form_sections = FormSection.all.sort{|item1, item2| (item1.order || "0") <=> (item2.order || "0")}
@form_sections = FormSection.all
end

def create
Expand Down
7 changes: 6 additions & 1 deletion app/models/form_section.rb
Expand Up @@ -10,7 +10,12 @@ class FormSection < CouchRestRails::Document
property :editable, :cast_as => 'boolean', :default => true

view_by :unique_id

view_by :order

def self.all
view 'by_order'
end

validates_presence_of :name
validates_format_of :name, :with =>/^([a-zA-Z0-9_\s]*)$/, :message=>"Name must contain only alphanumeric characters and spaces"

Expand Down

0 comments on commit 48287ab

Please sign in to comment.