Skip to content

Commit

Permalink
Only show serendipitous cards if a user is signed in and owns the con…
Browse files Browse the repository at this point in the history
…tent they're looking at
  • Loading branch information
drusepth committed Sep 25, 2016
1 parent 8e75458 commit 10aa258
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/controllers/content_controller.rb
Expand Up @@ -30,11 +30,13 @@ def show
# TODO: Secure this with content class whitelist lel
@content = content_type_from_controller(self.class).find(params[:id])

# question = QuestionService.question(Content.new @content.slice(*content_param_list.flat_map { |v| v.is_a?(Symbol) ? v : v.keys.map { |k| k.to_s.chomp('_attributes').to_sym } }))
begin
questionable_params = content_param_list.reject { |x| x.is_a?(Hash) || x.to_s.end_with?('_id') }
@question = QuestionService.question(Content.new @content.slice(*questionable_params))
rescue
if current_user and current_user == @content.user
# question = QuestionService.question(Content.new @content.slice(*content_param_list.flat_map { |v| v.is_a?(Symbol) ? v : v.keys.map { |k| k.to_s.chomp('_attributes').to_sym } }))
begin
questionable_params = content_param_list.reject { |x| x.is_a?(Hash) || x.to_s.end_with?('_id') }
@question = QuestionService.question(Content.new @content.slice(*questionable_params))
rescue
end
end

respond_to do |format|
Expand Down

0 comments on commit 10aa258

Please sign in to comment.