Commit 1be6d7f2da21c9905dc0f7fef6ad17f8067a185f
1 parent
89fde6ec
Exists in
master
fix: use default scope
Showing
3 changed files
with
4 additions
and
2 deletions
Show diff stats
lib/surveyable/acts_as_survey.rb
@@ -5,7 +5,7 @@ module Surveyable | @@ -5,7 +5,7 @@ module Surveyable | ||
5 | end | 5 | end |
6 | module ClassMethods | 6 | module ClassMethods |
7 | def acts_as_survey(options = {}) | 7 | def acts_as_survey(options = {}) |
8 | - has_many :questions, as: :survey, class_name: 'Surveyable::Question', order: "position ASC, id ASC" | 8 | + has_many :questions, as: :survey, class_name: 'Surveyable::Question' |
9 | send :include, InstanceMethods | 9 | send :include, InstanceMethods |
10 | end | 10 | end |
11 | end | 11 | end |
lib/surveyable/question.rb
@@ -9,6 +9,8 @@ module Surveyable | @@ -9,6 +9,8 @@ module Surveyable | ||
9 | validates_presence_of :text | 9 | validates_presence_of :text |
10 | validates_presence_of :type | 10 | validates_presence_of :type |
11 | 11 | ||
12 | + default_scope order: "position ASC, id ASC" | ||
13 | + | ||
12 | scope :required, -> { where(required:true)} | 14 | scope :required, -> { where(required:true)} |
13 | def field_type | 15 | def field_type |
14 | 'text' | 16 | 'text' |
lib/surveyable/version.rb