Skip to content

Integer

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

Integer type settings

Setting

Sail.set(:my_int_setting, 123)
Sail.set(:my_int_setting, "123")

Getting

Sail.get(:my_int_setting)
=> 123

Sail.get(:my_int_setting) do |setting_value|
  puts setting_value
end
=> 123

Examples

Integer type settings return a configurable number. They can be used as limits or page set up, for example.

Take the following code as a possible use case. Here, a given user has a limit of submissions that is configurable using Sail.

# app/models/user.rb

class User < ApplicationRecord
  .
  .

  def submit_answer
    answer.submit! unless answers.count >= Sail.get(:maximum_submissions)
  end
end
Clone this wiki locally