diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 057bde02..d3c36425 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -82,8 +82,13 @@ class ContentController < ApplicationController end def edit - @content = content_type_from_controller(self.class) - .find(params[:id]) + content_type_class = content_type_from_controller(self.class) + @content = content_type_class.find_by(id: params[:id]) + + if @content.nil? + return redirect_to root_path, + notice: "Either this #{content_type_class.name.downcase} doesn't exist, or you don't have access to view it." + end unless @content.updatable_by? current_user return redirect_to @content, notice: t(:no_do_permission) @@ -238,8 +243,8 @@ class ContentController < ApplicationController private def migrate_old_style_field_values - content ||= content_type_from_controller(self.class).find(params[:id]) - TemporaryFieldMigrationService.migrate_fields_for_content(content, current_user) + content ||= content_type_from_controller(self.class).find_by(id: params[:id]) + TemporaryFieldMigrationService.migrate_fields_for_content(content, current_user) if content.present? end def valid_content_types diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3a3ea7b1..df6301fb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,7 +27,7 @@ class UsersController < ApplicationController def delete_my_account # :( unless user_signed_in? - redirect_to root_path + redirect_to(root_path, notice: "You must be signed in to do that!") return end @@ -40,7 +40,7 @@ class UsersController < ApplicationController report_user_deletion_to_slack(current_user) current_user.really_destroy! - redirect_to root_path, notice: 'Your account has been deleted. We will miss you greatly!' + redirect_to(root_path, notice: 'Your account has been deleted. We will miss you greatly!') end def report_user_deletion_to_slack user diff --git a/app/views/content/edit.html.erb b/app/views/content/edit.html.erb index c62900a0..f563acac 100644 --- a/app/views/content/edit.html.erb +++ b/app/views/content/edit.html.erb @@ -16,14 +16,14 @@ <% end %> - +<% end %> <% if @content.persisted? %> <%= render partial: 'content/share', locals: { shared_content: @content} %> diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index 68b01292..eecedfdc 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -163,5 +163,6 @@ diff --git a/app/views/main/recent_content.html.erb b/app/views/main/recent_content.html.erb index ea79222a..5f6670b4 100644 --- a/app/views/main/recent_content.html.erb +++ b/app/views/main/recent_content.html.erb @@ -3,4 +3,4 @@