CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 31 Jul 2025 10:09:53 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090215024500
location: https://web.archive.org/web/20090215024500/https://github.com/simplificator/has_setting
server-timing: captures_list;dur=0.924084, exclusion.robots;dur=0.028925, exclusion.robots.policy;dur=0.013728, esindex;dur=0.013724, cdx.remote;dur=57.711454, LoadShardBlock;dur=329.670124, PetaboxLoader3.datanode;dur=86.271433, PetaboxLoader3.resolve;dur=170.661375
x-app-server: wwwb-app219
x-ts: 302
x-tr: 434
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: SERVER=wwwb-app219; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 301
server: nginx
date: Thu, 31 Jul 2025 10:09:53 GMT
content-type: text/html; charset=utf-8
content-length: 121
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sun, 15 Feb 2009 02:44:59 GMT
x-archive-orig-connection: close
x-archive-orig-status: 301 Moved Permanently
location: https://web.archive.org/web/20090215024500/https://github.com/simplificator/has_setting/tree/master
x-archive-orig-x-runtime: 22ms
x-archive-orig-cache-control: no-cache
x-archive-orig-content-length: 121
cache-control: max-age=1800
memento-datetime: Sun, 15 Feb 2009 02:45:00 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sun, 15 Feb 2009 02:45:00 GMT", ; rel="memento"; datetime="Sun, 15 Feb 2009 02:45:00 GMT", ; rel="last memento"; datetime="Sun, 15 Feb 2009 02:45:00 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090215012702_crawl103-c/52_8_20090215024318_crawl101.arc.gz
server-timing: captures_list;dur=1.102384, exclusion.robots;dur=0.020009, exclusion.robots.policy;dur=0.010438, esindex;dur=0.011060, cdx.remote;dur=14.008760, LoadShardBlock;dur=159.289733, PetaboxLoader3.datanode;dur=97.158037, PetaboxLoader3.resolve;dur=143.475536, load_resource;dur=159.973584
x-app-server: wwwb-app219
x-ts: 301
x-tr: 360
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 31 Jul 2025 10:09:54 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sun, 15 Feb 2009 02:45:00 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-x-runtime: 141ms
x-archive-orig-etag: "ae1ee7ef5c1d8daf4dc8de8a01763118"
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-orig-content-length: 25192
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 15 Feb 2009 02:45:00 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 13 Feb 2009 22:12:35 GMT", ; rel="prev memento"; datetime="Fri, 13 Feb 2009 22:12:35 GMT", ; rel="memento"; datetime="Sun, 15 Feb 2009 02:45:00 GMT", ; rel="next memento"; datetime="Tue, 23 Jun 2009 06:33:06 GMT", ; rel="last memento"; datetime="Sun, 02 Aug 2009 18:48:19 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090215012702_crawl103-c/52_8_20090215024318_crawl101.arc.gz
server-timing: captures_list;dur=0.772867, exclusion.robots;dur=0.033103, exclusion.robots.policy;dur=0.017641, esindex;dur=0.019180, cdx.remote;dur=27.102390, LoadShardBlock;dur=196.050536, PetaboxLoader3.datanode;dur=121.345738, PetaboxLoader3.resolve;dur=141.147565, load_resource;dur=89.636544
x-app-server: wwwb-app219
x-ts: 200
x-tr: 364
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
simplificator's has_setting at master - GitHub
This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (

This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (

Run the following if you haven't already:
gem sources -a https://gems.github.com
Install the gem(s):
sudo gem install simplificator-has_setting
Description: | a simple AR extension to manage settings (i.e. user has many settings) |
Homepage: | https://simplificator.com/en/labs |
Clone URL: |
git://github.com/simplificator/has_setting.git
Give this clone URL to anyone.
git clone git://github.com/simplificator/has_setting.git
|
name | age | message | |
---|---|---|---|
![]() |
.gitignore | Wed Feb 04 13:57:43 -0800 2009 | cleanup and description in gemspec [pascalbetz] |
![]() |
README | Sat Feb 07 08:00:58 -0800 2009 | version 0.3.9 of the gem [pascalbetz] |
![]() |
Rakefile | Wed Feb 04 13:57:43 -0800 2009 | cleanup and description in gemspec [pascalbetz] |
![]() |
VERSION.yml | Sat Feb 07 08:00:38 -0800 2009 | Version bump to 0.3.9 [pascalbetz] |
![]() |
has_setting.gemspec | Sat Feb 07 08:01:04 -0800 2009 | Regenerated gemspec for version 0.3.9 [pascalbetz] |
![]() |
help/ | Mon Feb 02 09:54:13 -0800 2009 | initial [pascal] |
![]() |
lib/ | Sat Feb 07 08:00:58 -0800 2009 | version 0.3.9 of the gem [pascalbetz] |
![]() |
test/ | Sat Feb 07 08:00:58 -0800 2009 | version 0.3.9 of the gem [pascalbetz] |
==What is it? has_setting is a simple extension that enables ActiveRecord models to store settings in a separate settings table as key/value pairs where the key and value are stored as Strings. ==History * 0.3.9: * added type :strings, :floats, :ints. They store the contents of an array as a comma separated string. * 0.3.8: * added dependent destroy option. no more zombie settings lingering around. * 0.3.7: * Gem is now built using jeweler... after messing around and bumping versions and getting strange errors, this is 'it works' feeling coming back * 0.3.4: * Added custom formatter support. no new formatters though... * 0.3.1: * Bug Fixed: has_many(:settings) is not added to ActiveRecord::Base but only to the classes with has_setting * Bug Fixed: options are not shared between classes * Again changed the way settings are saved. Save is now done on parent.save with an after_save callback. (like this the settings are treated as if they were attributes of the owner) * 0.2.x: * Added :default option * changed way settings are saved so that unsaved parents can have settings too * changed nameing scheme of setting names (incompatible with versions prior 0.2.x but since nobody uses the gem i dont care :-)) * 0.1.x: First Version ==Installation sudo gem install simplificator-has_setting ==Setup * Add a migration that looks more or less like the one in <em>help/001_create_settings.rb</em> * Make sure the gem is loaded when your application starts ==Config The model you want to hold settings (i.e. User, Profile, ...): <tt>has_setting(:name_of_the_setting)</tt> This will create the following methods for you on the owner class: * <tt>name_of_the_setting=(value)</tt> a standard setter * <tt>name_of_the_setting()</tt> a standard getter (the getter method takes an optional hash to override some options, possible values are the same as the options in has_setting()) <tt>has_setting(name, options)</tt> takes an optional hash of options. Following options are supported: <em>:type</em> allows you to convert the value: * <em>:string</em> (default) Uses the StringFormatter to convert from/to String (actually this formatter just leaves the value as it is) * <em>:int</em> Uses the IntFormatter to convert from/to int values. * <em>:float</em> Uses the FloatFormatter to convert from/to float values. * <em>:ints</em> Uses the IntsFormatter to convert from/to int[] * <em>:floats</em> Uses the FloatsFormatter to convert from/to float[] * <em>:strings</em> Uses the StringsFormatter to convert from/to string[] <em>:default</em> allows you to specify a default value that will be returned if the setting does not exist (i.e. has never been written). Note that the default value is _ignored_ if the setting exists, no matter what the value of the setting is. The default value is returned as is, no type conversion takes place. ==How it works A polymorphic parent-child relation is created between Setting and the parent/owning class. Getters/setters are added through meta-programming-magic. If the setter is invoked on a unsafed parent then the setting is not saved until the parent is saved, else setting is saved upon creation (i.e. first time the setter is called) / change (subsequent calls). The getters/setters can be used in standard AR validations, Rails mass assignments/form helpers and so on. ==Gotchas * Values are stored as Strings in the DB. Values are converted with one of the formatters (depending on selected :type). If you try to store an unsupported type or anything other than the type you selected there might be an exception (i.e. if you try to store "foobar" as an :type => :int) * Currently there are no length validations on the 'name' and 'value' column of Setting. Take care not to store values to big. Especially when using the array formatters (:floats, :ints, :strings) ==Example <code> class Foo < ActiveRecord::Base has_setting(:string_setting) has_setting(:another_string_setting, :type => :string) has_setting(:int_setting, :type => :int) has_setting(:float_setting, :type => :float, :default => 3.3) end foo = Foo.create foo.string_setting => nil foo.string_setting= 'a string' foo.string_setting => 'a string' foo.int_setting = 123 foo.int_setting => 123 foo.int_setting = '123' foo.int_setting => 123 foo.float_setting => 3.3 foo.float_setting = nil foo.float_setting => nil </code> ==Todo has_setting should stay as simple as possible... still some ideas are around: * Custom formatter (to convert arbitrary objects, i.e. Date/Time/DateTime...) * Add validation options
This feature is coming soon. Sit tight!