Remove CurrentUser.ip_addr.
Remove the `CurrentUser.ip_addr` global variable and replace it with `request.remote_ip`. Before we had to track the current user's IP in a global variable so that when we edited a post for example, we could pass down the user's IP to the model and save it in the post_versions table. Now that we now longer save IPs in version tables, we don't need a global variable to get access to the current user's IP outside of controllers.
This commit is contained in:
@@ -38,7 +38,7 @@ class ForumPostsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@forum_post = authorize ForumPost.new(creator: CurrentUser.user, creator_ip_addr: CurrentUser.ip_addr, topic_id: params.dig(:forum_post, :topic_id))
|
||||
@forum_post = authorize ForumPost.new(creator: CurrentUser.user, creator_ip_addr: request.remote_ip, topic_id: params.dig(:forum_post, :topic_id))
|
||||
@forum_post.update(permitted_attributes(@forum_post))
|
||||
|
||||
page = @forum_post.topic.last_page if @forum_post.topic.last_page > 1
|
||||
|
||||
Reference in New Issue
Block a user