From fe3aa2f368e93213f423620ef58286a9feb32c1d Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Tue, 18 Feb 2020 22:36:49 +0800 Subject: [PATCH] fix: add question sorting support --- Gemfile | 2 +- README.md | 1 + lib/surveyable/question.rb | 3 +++ lib/surveyable/version.rb | 2 +- surveyable.gemspec | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a8a8408..bcb7ca4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' # Specify your gem's dependencies in surveyable.gemspec -gemspec +gemspec \ No newline at end of file diff --git a/README.md b/README.md index d31ceb8..ebcf209 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Run migrations (to be included as files soon) t.text :text t.string :type t.boolean :required + t.integer :position end create_table :answers do |t| t.integer :question_id diff --git a/lib/surveyable/question.rb b/lib/surveyable/question.rb index 69a825c..86e608d 100644 --- a/lib/surveyable/question.rb +++ b/lib/surveyable/question.rb @@ -1,5 +1,8 @@ module Surveyable class Question < ActiveRecord::Base + include RankedModel + ranks :position + belongs_to :survey, polymorphic: true has_many :answers, :dependent => :restrict_with_error has_many :answer_choices, dependent: :destroy diff --git a/lib/surveyable/version.rb b/lib/surveyable/version.rb index 47d5c89..e34a506 100644 --- a/lib/surveyable/version.rb +++ b/lib/surveyable/version.rb @@ -1,3 +1,3 @@ module Surveyable - VERSION = "0.2.0" + VERSION = "0.2.1" end diff --git a/surveyable.gemspec b/surveyable.gemspec index 69aea03..3119f97 100644 --- a/surveyable.gemspec +++ b/surveyable.gemspec @@ -22,4 +22,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.10" #spec.add_development_dependency "rake", "~> 10.0" spec.add_runtime_dependency "activerecord", "~> 5.0" + spec.add_runtime_dependency "ranked-model", "~> 0.4.0" end -- libgit2 0.21.0