Model.order("id desc").all
などとするが、時々この中の一部(例えばID:3)は先頭に、それ以外はIDの降順にしたいときなどがある。そんなときは、
Model.order("'id' = CASE WHEN id = 3 THEN 0 ELSE 'id' END").order("id desc").all
などとすると、できる。
Model.order("id desc").all
などとするが、時々この中の一部(例えばID:3)は先頭に、それ以外はIDの降順にしたいときなどがある。Model.order("'id' = CASE WHEN id = 3 THEN 0 ELSE 'id' END").order("id desc").all
などとすると、できる。
gem 'chanko', :git => 'git://github.com/cookpad/chanko.git' gem "vanity"を記述して、
development: adapter: active_record active_record_adapter: mysql2 host: localhost database: DBNAME user: USERNAME password: PASSWORD
Vanity.playground.collecting = true
class VanityController < ApplicationController include Vanity::Rails::Dashboard end
match '/vanity(/:action(/:id(.:format)))', :controller=>:vanity
class ApplicationController < ActionController::Base use_vanity :current_user end
metric "Post" do description "Postした回数" end
class PostController < ApplicationController
def create
track! :post
# ...投稿する処理
end
end
end
ab_test "Post labels" do description "テスト" alternatives true, false metrics :post end
module Sample
include Chanko::Unit
active_if do |context, options|
ab_test(:price_options)
end
scope(:controller) do
function(:controller_show) do
# controller code here
end
end
scope(:view) do
function(:view_show) do
render :partial => "/show"
end
end
end
で、好きな場所にinvoke(:sample, :controller_show) をおいたり、production: adapter: redis host: localhost