Skip to content

Instantly share code, notes, and snippets.

@cvd
Created May 21, 2014 17:09
Show Gist options
  • Save cvd/0933256b3ae0283f7d0a to your computer and use it in GitHub Desktop.
Save cvd/0933256b3ae0283f7d0a to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb
index 7231f45..697d946 100644
--- a/app/controllers/students_controller.rb
+++ b/app/controllers/students_controller.rb
@@ -3,6 +3,7 @@ class StudentsController < ApplicationController
before_filter :require_student_login, :only => %w[home profile update_profile support redirect_to_survey record_survey_result game]
before_filter :require_teacher_login, :only => %w[index new create edit update, :atwork_index]
+ before_filter :find_survey_by_slug, only: [:redirect_to_survey]
protect_from_forgery :except => :update_profile
has_scope :fulltext, :as => :term
@@ -315,4 +316,11 @@ class StudentsController < ApplicationController
SQL
end
+ def find_survey_by_slug
+ if params[:survey_id].blank? && params[:survey_slug].present?
+ survey = Survey.find_by_slug(params[:survey_slug])
+ params[:survey_id] = survey.id if survey.present?
+ end
+ end
+
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment