Skip to content

Obj model

Vinicius Stock edited this page Feb 19, 2019 · 4 revisions

Obj model type settings

Setting

Sail.set(:my_model_setting, "Post")
Sail.set(:my_model_setting, Post)

Getting

Sail.get(:my_model_setting)
=> Post

Sail.get(:my_model_setting) do |setting_value|
  puts setting_value
end
=> Post

Examples

Obj model type settings return the class for a given model from the Rails application. One use case of this is testing out two different implementations of a similar model either to compare their performance or to make a safe refactor.

class ArticlesController < ApplicationController
  def index
    Sail.get(:model_for_articles).where(author: "John")
  end
end
Clone this wiki locally