From 1c61e45146aa81938eefd846c360e0cf6bd1d307 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 6 Oct 2015 16:05:15 +0300 Subject: [PATCH] Store the remote host from which the preference originated --- app/controllers/application_controller.rb | 7 +++++++ app/controllers/talk_preferences_controller.rb | 1 + 2 files changed, 8 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..85da787 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,11 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + protected + + def current_ip_address + # request.env['HTTP_X_FORWARDED_FOR'] || + request.remote_ip + end end diff --git a/app/controllers/talk_preferences_controller.rb b/app/controllers/talk_preferences_controller.rb index 8de38ad..8a9c48c 100644 --- a/app/controllers/talk_preferences_controller.rb +++ b/app/controllers/talk_preferences_controller.rb @@ -10,6 +10,7 @@ class TalkPreferencesController < ApplicationController def create @talk_preference = TalkPreference.new talk_preference_params + @talk_preference.ip_address = current_ip_address if @talk_preference.save render json: {