Module: Spree::Preferences::ModelHooks
- Defined in:
- lib/spree/preferences/model_hooks.rb
Overview
Adds support for defining preferences on ActiveRecord models.
Saving preferences
Preferences are not automatically saved when they are set. You must save the record that the preferences were set on.
For example,
class User < ActiveRecord::Base
preference :notifications
end
u = User.new(:login => 'admin', :prefers_notifications => false)
u.save!
u = User.find_by_login('admin')
u.attributes = {:prefers_notifications => true}
u.save!
Defined Under Namespace
Modules: InstanceMethods, MacroMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Class Method Details
.included(base) ⇒ Object
:nodoc:
28 29 30 31 32 |
# File 'lib/spree/preferences/model_hooks.rb', line 28 def self.included(base) #:nodoc: base.class_eval do extend Spree::Preferences::ModelHooks::MacroMethods end end |