Commit fe3aa2f368e93213f423620ef58286a9feb32c1d
1 parent
6fc5077d
Exists in
master
fix: add question sorting support
Showing
5 changed files
with
7 additions
and
2 deletions
Show diff stats
Gemfile
README.md
@@ -30,6 +30,7 @@ Run migrations (to be included as files soon) | @@ -30,6 +30,7 @@ Run migrations (to be included as files soon) | ||
30 | t.text :text | 30 | t.text :text |
31 | t.string :type | 31 | t.string :type |
32 | t.boolean :required | 32 | t.boolean :required |
33 | + t.integer :position | ||
33 | end | 34 | end |
34 | create_table :answers do |t| | 35 | create_table :answers do |t| |
35 | t.integer :question_id | 36 | t.integer :question_id |
lib/surveyable/question.rb
1 | module Surveyable | 1 | module Surveyable |
2 | class Question < ActiveRecord::Base | 2 | class Question < ActiveRecord::Base |
3 | + include RankedModel | ||
4 | + ranks :position | ||
5 | + | ||
3 | belongs_to :survey, polymorphic: true | 6 | belongs_to :survey, polymorphic: true |
4 | has_many :answers, :dependent => :restrict_with_error | 7 | has_many :answers, :dependent => :restrict_with_error |
5 | has_many :answer_choices, dependent: :destroy | 8 | has_many :answer_choices, dependent: :destroy |
lib/surveyable/version.rb
surveyable.gemspec
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec| | @@ -22,4 +22,5 @@ Gem::Specification.new do |spec| | ||
22 | spec.add_development_dependency "bundler", "~> 1.10" | 22 | spec.add_development_dependency "bundler", "~> 1.10" |
23 | #spec.add_development_dependency "rake", "~> 10.0" | 23 | #spec.add_development_dependency "rake", "~> 10.0" |
24 | spec.add_runtime_dependency "activerecord", "~> 5.0" | 24 | spec.add_runtime_dependency "activerecord", "~> 5.0" |
25 | + spec.add_runtime_dependency "ranked-model", "~> 0.4.0" | ||
25 | end | 26 | end |