From a1095aeea1d4bf6874fc7340b40e687261aee3d9 Mon Sep 17 00:00:00 2001 From: Brice Sanchez Date: Wed, 9 Sep 2015 16:39:57 -0400 Subject: [PATCH 1/2] Fix hide collapse questions --- lib/assets/javascripts/surveyor/jquery.surveyor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assets/javascripts/surveyor/jquery.surveyor.js b/lib/assets/javascripts/surveyor/jquery.surveyor.js index 4398ff8c..4885b8d4 100644 --- a/lib/assets/javascripts/surveyor/jquery.surveyor.js +++ b/lib/assets/javascripts/surveyor/jquery.surveyor.js @@ -106,7 +106,7 @@ jQuery(document).ready(function(){ } if ( detail_info ){ - $(detail_info).collapse('hide'); + $(detail_info).hide; } $this.hideElement(this) } From 1c3f59282a83d6668c0d5b43de25374cc4f61181 Mon Sep 17 00:00:00 2001 From: Brice Sanchez Date: Wed, 25 Nov 2015 14:04:19 -0500 Subject: [PATCH 2/2] Ability to define a custom user_class --- lib/generators/surveyor/install_generator.rb | 4 ++++ lib/surveyor.rb | 10 ++++++++++ lib/surveyor/models/response_set_methods.rb | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/generators/surveyor/install_generator.rb b/lib/generators/surveyor/install_generator.rb index 2694df81..5d954d48 100644 --- a/lib/generators/surveyor/install_generator.rb +++ b/lib/generators/surveyor/install_generator.rb @@ -40,6 +40,10 @@ class InstallGenerator < Rails::Generators::Base add_input_mask_attributes_to_answer ) + def create_initializer_file + create_file "config/initializers/surveyor.rb", "Surveyor.user_class = 'User'" + end + def readme copy_file "../../../../README.md", "surveys/README.md" end diff --git a/lib/surveyor.rb b/lib/surveyor.rb index 50acc4f3..27cd3a52 100644 --- a/lib/surveyor.rb +++ b/lib/surveyor.rb @@ -2,6 +2,16 @@ module Surveyor require 'surveyor/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 autoload :VERSION, 'surveyor/version' autoload :ParserError, 'surveyor/parser' + + mattr_accessor :user_class + + def self.user_class + if @@user_class.is_a?(Class) + raise "Surveyor.user_class MUST be a String or Symbol object, not a Class object." + elsif @@user_class.is_a?(String) || @@user_class.is_a?(Symbol) + @@user_class.to_s.constantize + end + end end require 'surveyor/common' require 'surveyor/acts_as_response' diff --git a/lib/surveyor/models/response_set_methods.rb b/lib/surveyor/models/response_set_methods.rb index 0bc830a5..5e17bbb8 100644 --- a/lib/surveyor/models/response_set_methods.rb +++ b/lib/surveyor/models/response_set_methods.rb @@ -8,7 +8,7 @@ module ResponseSetMethods included do # Associations belongs_to :survey - belongs_to :user + belongs_to :user, class_name: Surveyor.user_class has_many :responses, :dependent => :destroy accepts_nested_attributes_for :responses, :allow_destroy => true attr_accessible *PermittedParams.new.response_set_attributes if defined? ActiveModel::MassAssignmentSecurity