README.md in field_test-0.3.1 vs README.md in field_test-0.3.2
- old
+ new
@@ -149,19 +149,37 @@
```ruby
field_test(:button_color, participant: company)
```
+## Jobs
+
+To get variants in jobs, models, and other contexts, use:
+
+```ruby
+experiment = FieldTest::Experiment.find(:button_color)
+button_color = experiment.variant(user)
+```
+
## Config
By default, bots are returned the first variant and excluded from metrics. Change this with:
```yml
exclude:
bots: false
```
+Exclude certain IP addresses with:
+
+```yml
+exclude:
+ ips:
+ - 127.0.0.1
+ - 10.0.0.0/8
+```
+
Keep track of when experiments started and ended. Use any format `Time.parse` accepts. Variants assigned outside this window are not included in metrics.
```yml
experiments:
button_color:
@@ -279,21 +297,23 @@
```ruby
ENV["FIELD_TEST_USERNAME"] = "moonrise"
ENV["FIELD_TEST_PASSWORD"] = "kingdom"
```
-## Reference
+## Updating Variants
Assign a specific variant to a user with:
```ruby
experiment = FieldTest::Experiment.find(:button_color)
experiment.variant(participant, variant: "green")
```
You can also change a user’s variant from the dashboard.
+## Associations
+
To associate models with field test memberships, use:
```ruby
class User < ApplicationRecord
has_many :field_test_memberships, class_name: "FieldTest::Membership", as: :participant
@@ -339,11 +359,11 @@
```
with:
```ruby
-class UpgradeFieldTestParticipants < ActiveRecord::Migration[5.2]
+class UpgradeFieldTestParticipants < ActiveRecord::Migration[6.0]
def change
add_column :field_test_memberships, :participant_type, :string
add_column :field_test_memberships, :participant_id, :string
add_index :field_test_memberships, [:participant_type, :participant_id, :experiment],
@@ -390,5 +410,14 @@
- [Report bugs](https://github.com/ankane/field_test/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/field_test/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features
+
+To get started with development:
+
+```sh
+git clone https://github.com/ankane/field_test.git
+cd field_test
+bundle install
+bundle exec rake test
+```