README.md in flex_commerce_api-0.7 vs README.md in flex_commerce_api-0.8.1
- old
+ new
@@ -10,37 +10,72 @@
gem 'flex-commerce-api'
```
And then execute:
- $ bundle
+```
+$ bundle
+```
Or install it yourself as:
- $ gem install flex-commerce-api
+```
+$ gem install flex-commerce-api
+```
## Usage
-The gem provides many models in the FlexCommerce namespace. The example below is a rails controller
+The gem provides many models in the FlexCommerce namespace. The example below is a rails controller
accessing a list of products.
```ruby
class ProductsController < ApplicationController
# GET /products
def index
@products = FlexCommerce::Product.paginate(params[:page])
end
end
-
```
To any rails developer this will look familiar.
However, we do not force you to use rails. We appreciate that there are many frameworks out there
and whilst rails is an excellent tool, for smaller projects you may want to look at others such
-as sinatra etc...
+as Sinatra etc...
+### Client IP address tracing in Rails apps
+
+Add the request store gem to your Gemfile and install
+
+```ruby
+gem "request-store"
+```
+
+```sh
+bundle install
+```
+
+```ruby
+# application_controller.rb
+class ApplicationController
+ before_action :set_request_ip
+
+ private
+
+ def set_request_ip
+ RequestStore[:request_ip] = request.remote_ip
+ end
+end
+```
+
+Configure the API client to pick up set value
+
+```ruby
+FlexCommerceApi.config do |config|
+ config.forwarded_for = ->{ RequestStore[:request_ip] }
+end
+```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.