Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use strong params (if loaded) to transition from rails 3 #512

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/surveyor/models/answer_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module AnswerMethods
belongs_to :question
has_many :responses
has_many :validations, :dependent => :destroy
attr_accessible *PermittedParams.new.answer_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.answer_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :text
Expand Down
2 changes: 1 addition & 1 deletion lib/surveyor/models/dependency_condition_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module DependencyConditionMethods
belongs_to :dependency
belongs_to :dependent_question, :foreign_key => :question_id, :class_name => :question
belongs_to :question
attr_accessible *PermittedParams.new.dependency_condition_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.dependency_condition_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :operator, :rule_key
Expand Down
4 changes: 2 additions & 2 deletions lib/surveyor/models/dependency_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module DependencyMethods
belongs_to :question
belongs_to :question_group
has_many :dependency_conditions, :dependent => :destroy
attr_accessible *PermittedParams.new.dependency_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.dependency_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :rule
Expand Down Expand Up @@ -54,4 +54,4 @@ def conditions_hash(response_set)
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/surveyor/models/question_group_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module QuestionGroupMethods
# Associations
has_many :questions
has_one :dependency
attr_accessible *PermittedParams.new.question_group_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.question_group_attributes unless defined? ActiveModel::ForbiddenAttributesProtection
end

# Instance Methods
Expand Down Expand Up @@ -59,4 +59,4 @@ def translation(locale)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/surveyor/models/question_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module QuestionMethods
has_many :answers, :dependent => :destroy # it might not always have answers
has_one :dependency, :dependent => :destroy
belongs_to :correct_answer, :class_name => "Answer", :dependent => :destroy
attr_accessible *PermittedParams.new.question_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.question_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :text, :display_order
Expand Down
2 changes: 1 addition & 1 deletion lib/surveyor/models/response_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ResponseMethods
belongs_to :response_set
belongs_to :question
belongs_to :answer
attr_accessible *PermittedParams.new.response_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.response_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :question_id, :answer_id
Expand Down
2 changes: 1 addition & 1 deletion lib/surveyor/models/response_set_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ResponseSetMethods
belongs_to :user
has_many :responses, :dependent => :destroy
accepts_nested_attributes_for :responses, :allow_destroy => true
attr_accessible *PermittedParams.new.response_set_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.response_set_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :survey_id
Expand Down
2 changes: 1 addition & 1 deletion lib/surveyor/models/survey_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module SurveyMethods
has_many :sections, class_name: 'SurveySection', :dependent => :destroy
has_many :response_sets
has_many :translations, :class_name => "SurveyTranslation"
attr_accessible *PermittedParams.new.survey_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.survey_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :title
Expand Down
2 changes: 1 addition & 1 deletion lib/surveyor/models/survey_section_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module SurveySectionMethods
# Associations
has_many :questions, :dependent => :destroy
belongs_to :survey
attr_accessible *PermittedParams.new.survey_section_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.survey_section_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :title, :display_order
Expand Down
4 changes: 2 additions & 2 deletions lib/surveyor/models/survey_translation_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module SurveyTranslationMethods
included do
# Associations
belongs_to :survey
attr_accessible *PermittedParams.new.survey_translation_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.survey_translation_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :locale, :translation
Expand All @@ -25,4 +25,4 @@ def default_args
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/surveyor/models/validation_condition_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ValidationConditionMethods
included do
# Associations
belongs_to :validation
attr_accessible *PermittedParams.new.validation_condition_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.validation_condition_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :operator, :rule_key
Expand Down
4 changes: 2 additions & 2 deletions lib/surveyor/models/validation_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ValidationMethods
# Associations
belongs_to :answer
has_many :validation_conditions, :dependent => :destroy
attr_accessible *PermittedParams.new.validation_attributes if defined? ActiveModel::MassAssignmentSecurity
attr_accessible *PermittedParams.new.validation_attributes unless defined? ActiveModel::ForbiddenAttributesProtection

# Validations
validates_presence_of :rule
Expand Down Expand Up @@ -38,4 +38,4 @@ def conditions_hash(response_set)
end
end
end
end
end