Store the remote host from which the preference originated

This commit is contained in:
Petko Bordjukov 2015-10-06 16:05:15 +03:00
parent 5d718ba214
commit 1c61e45146
No known key found for this signature in database
GPG Key ID: 2ABD54A3A1D5078A
2 changed files with 8 additions and 0 deletions

View File

@ -2,4 +2,11 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception. # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :exception
protected
def current_ip_address
# request.env['HTTP_X_FORWARDED_FOR'] ||
request.remote_ip
end
end end

View File

@ -10,6 +10,7 @@ class TalkPreferencesController < ApplicationController
def create def create
@talk_preference = TalkPreference.new talk_preference_params @talk_preference = TalkPreference.new talk_preference_params
@talk_preference.ip_address = current_ip_address
if @talk_preference.save if @talk_preference.save
render json: { render json: {