-
Notifications
You must be signed in to change notification settings - Fork 32
Integer
Vinicius Stock edited this page Feb 19, 2019
·
3 revisions
Sail.set(:my_int_setting, 123)
Sail.set(:my_int_setting, "123")
Sail.get(:my_int_setting)
=> 123
Sail.get(:my_int_setting) do |setting_value|
puts setting_value
end
=> 123
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