LoginSignup
0
1

More than 5 years have passed since last update.

gem splitの使い方

Posted at

★herokuの設定

heroku addons:add rediscloud:25

/config/initializer/redis.rb
namespace = [Rails.application.class.parent_name, Rails.env].join ':'

if Rails.env == "development"
  Redis.current = Redis::Namespace.new(namespace, Redis.new(host: '127.0.0.1', port: 6379))
else
  if ENV["REDISCLOUD_URL"]
      $redis = Redis.new(:url => ENV["REDISCLOUD_URL"])
  end
end
/config/initializer/split.rb

unless Rails.env == "development"
  Split.redis = $redis
  Split::Dashboard.use Rack::Auth::Basic do |username, password|
    username == 'admin' && password == Rails.application.config.admin_password
  end
end

★railsの設定

view

<% ab_test("item_show","list-type","card-type") do |pattern| %>
<% if pattern == "list-type" %>
 -- code here --
<% elsif pattern == "card-type" %>
 -- code here --
<% end %>

controller
finished('item_show', :reset => false)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1