Skip to content

pnomolos/rails-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RailsSettings
============

Right now this is only working for datamapper.  I will try to port to ActiveRecord shortly

Enable settings for your app or models

Add the slice as a regular dependency

dependency 'rails-settings'

Create a model that will hold all settings. Include the following as a
basis. No other includes are necessary.

class Setting
  include MerbSettings::Adapter::DataMapper
  include MerbSettings::Adapter::DataMapper::DefaultModelSetup
end

This then enables you to do the following:

Setting.foo = "test"
Setting.bar = 9
Setting.foo #=> "test"
Setting.foo = 9
Setting.foo #=> 9

To have settings that are scoped to a model include the following alongside
all your other model code:

class User
  include RailsSettings::ScopedMethods

  property :foo, ....

  setting :foo, 'text'
  setting :bar, 12
end

Notice that you can also set defaults for some settings so that if they are
called upon before they are set then you will get the default (this actually
is not working yet :-) )

------------------------------------------------------------------------------


About

A port of merb-settings for Rails 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages