Forum: Ruby on Rails ActsAsConfigurable?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Matthew Rudy J. (Guest)
on 2008-10-06 14:53
Hi there,
does anyone kow of an existing "ActsAsConfigurable" type plugin?

I want to say;

class Organisation
  acts_as_configurable :properties => {
    :some_property => {:type => :boolean, :default => false}

and then configure it by;

organisation.config_for(:some_property) # => false # the default
organisation.set_config_for(:some_property, true)

rather than cluttering up all of my tables with boolean flags.

If not, then I'm going to build it anyway.
So let me know if you're interested.

Matthew R. Jacobs
Matthew Rudy J. (Guest)
on 2008-10-06 18:36
Matthew R. Jacobs wrote:
> Hi there,
> does anyone kow of an existing "ActsAsConfigurable" type plugin?

This is what I came up with;

class Organisation < ActiveRecord::Base
  acts_as_configurable :some_property => {
    :default => "left",
    :options => ["left", "middle", "right"],
    :description => "Where should we put something?"}

then just;

organisation.some_property # uses the default if it has not been set
organisation.some_property = "middle"

Will add support for Boolean attributes some time soon.
This topic is locked and can not be replied to.