Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some docs

  • Loading branch information...
commit 90fb93caa182faaaadebe1a2921140133b0f8b25 1 parent e894e4e
@ledermann authored
Showing with 71 additions and 2 deletions.
  1. +71 −2 README.md
View
73 README.md
@@ -1,9 +1,23 @@
# Settings gem for Rails
-Complete rewrite
+[![Build Status](https://secure.travis-ci.org/ledermann/rails-settings.png)](http://travis-ci.org/ledermann/rails-settings)
+
+Handling settings for ActiveRecord objects (with defaults).
+
+**BEWARE: WORK IN PROGRESS!**
+
+
+## Requirements
+
+Rails 3.1.x or 3.2.x.
+
+Tested with Ruby 1.8.7, 1.9.3 and 2.0.0
+
# Example
+### Define Settings for a model with default values
+
```ruby
class User < ActiveRecord::Base
has_settings :dashboard => { :theme => 'blue', :view => 'monthly', :filter => false },
@@ -11,4 +25,59 @@ class User < ActiveRecord::Base
end
```
-Beware: Work in progress!
+### Set settings for a given object
+
+```ruby
+user = User.find(1)
+user.settings(:dashboard).theme = 'black'
+user.settings(:calendar).scope = 'all'
+user.settings(:calendar).display = 'daily'
+user.save!
+```
+
+or
+
+```ruby
+user = User.find(1)
+user.settings(:dashboard).update_attributes! :theme => 'black'
+user.settings(:calendar).update_attributes! :scope => 'all', :display => 'dialy'
+```
+
+
+### Get settings
+
+```ruby
+user = User.find(1)
+user.settings(:dashboard).theme
+# => 'black
+
+user.settings(:dashboard).view
+# => 'monthly' (it's default)
+
+user.settings(:calendar).scope
+# => 'all'
+```
+
+
+## Installation
+
+Include the gem in your Gemfile:
+
+```ruby
+gem 'ledermann-rails-settings', :require => 'rails-settings', :branch => 'rewrite'
+```
+
+Generate and run the migration:
+
+```shell
+rails g rails-settings:migration
+rake db:migrate
+```
+
+
+## License
+
+MIT License
+Copyright (c) 2013 Georg Ledermann
+
+This gem is a complete rewrite of [rails-settings](https://github.com/Squeegy/rails-settings) by [Alex Wayne](https://github.com/Squeegy)
Please sign in to comment.
Something went wrong with that request. Please try again.