Skip to content

Commit ebbc17d

Browse files
committed
Remove multi tenancy temporarily. Needs more thought
1 parent 5692032 commit ebbc17d

File tree

10 files changed

+11
-62
lines changed

10 files changed

+11
-62
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ methods `current_user` and `can_administer?` on your `ApplicationController`
5656
1. `current_user` : the user who is answering the survey. can be `nil`
5757
2. `can_administer?` : a method which determines whether current user can
5858
create/update survey questions.
59-
3. `owner_surveys_scope` : the scope of surveys for this entity, for multi-tenancy. Defaults to `Survey`
6059

6160
Typical implementation would be:
6261

@@ -69,10 +68,6 @@ class ApplicationController < ActionController::Base
6968
def can_administer?
7069
current_user.try(:admin?)
7170
end
72-
73-
def owner_surveys_scope
74-
current_user.surveys
75-
end
7671
end
7772
```
7873

app/controllers/rapidfire/application_controller.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ def authenticate_administrator!
1212
end
1313
end
1414

15-
def owner_surveys_scope
16-
if defined?(super)
17-
super
18-
else
19-
Survey
20-
end
21-
end
22-
2315
# Override prefixes to consider the scoped.
2416
# for method current_user
2517
def rapidfire_scoped

app/controllers/rapidfire/attempts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def update
3737
private
3838

3939
def find_survey!
40-
@survey = owner_surveys_scope.find(params[:survey_id])
40+
@survey = Survey.find(params[:survey_id])
4141
end
4242

4343
def attempt_params

app/controllers/rapidfire/questions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def save_and_redirect(params, on_error_key)
5555
end
5656

5757
def find_survey!
58-
@survey = owner_surveys_scope.find(params[:survey_id])
58+
@survey = Rapidfire::Survey.find(params[:survey_id])
5959
end
6060

6161
def find_question!

app/controllers/rapidfire/surveys_controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ class SurveysController < Rapidfire::ApplicationController
33
before_action :authenticate_administrator!, except: :index
44

55
def index
6-
@surveys = owner_surveys_scope.all
6+
@surveys = Rapidfire::Survey.all
77
@surveys = @surveys.page(params[:page]) if defined?(Kaminari)
88
@surveys
99
end
1010

1111
def new
12-
@survey = owner_surveys_scope.new
12+
@survey = Rapidfire::Survey.new
1313
end
1414

1515
def create
1616
source_survey = nil
1717
if params[:copy_survey_id]
18-
source_survey = owner_surveys_scope.find(params[:copy_survey_id])
19-
params[:survey] = source_survey.attributes.except(*%w(created_at updated_at id owner_id owner_type))
18+
source_survey = Rapidfire::Survey.find(params[:copy_survey_id])
19+
params[:survey] = source_survey.attributes.except(*%w(created_at updated_at id))
2020
params[:survey][:name] = "Copy of #{params[:survey][:name]}"
2121
end
22-
@survey = owner_surveys_scope.new(survey_params)
22+
@survey = Rapidfire::Survey.new(survey_params)
2323

2424
if source_survey
2525
source_survey.questions.each do |q|
@@ -41,11 +41,11 @@ def create
4141
end
4242

4343
def edit
44-
@survey = owner_surveys_scope.find(params[:id])
44+
@survey = Rapidfire::Survey.find(params[:id])
4545
end
4646

4747
def update
48-
@survey = owner_surveys_scope.find(params[:id])
48+
@survey = Rapidfire::Survey.find(params[:id])
4949
if @survey.update(survey_params)
5050
respond_to do |format|
5151
format.html { redirect_to surveys_path }
@@ -60,7 +60,7 @@ def update
6060
end
6161

6262
def destroy
63-
@survey = owner_surveys_scope.find(params[:id])
63+
@survey = Rapidfire::Survey.find(params[:id])
6464
@survey.destroy
6565

6666
respond_to do |format|
@@ -71,7 +71,7 @@ def destroy
7171

7272
def results
7373
params[:filter] ||= {}
74-
@survey = owner_surveys_scope.find(params[:id])
74+
@survey = Rapidfire::Survey.find(params[:id])
7575
@survey_results =
7676
SurveyResults.new(survey: @survey).extract(filter_params)
7777

app/models/rapidfire/survey.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'csv'
22
module Rapidfire
33
class Survey < ApplicationRecord
4-
belongs_to :owner, :polymorphic => true, optional: true
54
has_many :attempts
65
has_many :questions
76

db/migrate/20170701163638_add_owner_to_survey.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/generators/rapidfire/multitenant_migration_generator.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/generators/rapidfire/templates/migrations/add_owner_to_survey.rb

Lines changed: 0 additions & 6 deletions
This file was deleted.

spec/factories/surveys_factory.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
factory :survey, :class => "Rapidfire::Survey" do
33
name "Test Survey"
44
introduction "Please answer all the questions in this survey."
5-
owner { FactoryGirl.create(:user) }
65
end
76
end

0 commit comments

Comments
 (0)