add active admin and more code work
This commit is contained in:
parent
d910e0e837
commit
fb93632750
10
README.md
10
README.md
@ -44,8 +44,12 @@ class DatabaseObjectFormObject < CandyWrapper::ModelWrapper
|
||||
end
|
||||
```
|
||||
|
||||
## Coming soon!
|
||||
Also, plug it into ActiveAdmin super-easily, which is where I typicallty
|
||||
use it!
|
||||
|
||||
* Form objects that hang off of models as if they were relationships
|
||||
* A better readme!
|
||||
``` ruby
|
||||
ActiveAdmin.register Model do
|
||||
wrap_in_form_object
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -2,3 +2,6 @@ require "candy_wrapper/version"
|
||||
require "candy_wrapper/model_wrapper"
|
||||
require "candy_wrapper/inherited_resources"
|
||||
|
||||
if defined?(ActiveAdmin)
|
||||
require 'candy_wrapper/active_admin'
|
||||
end
|
||||
|
9
lib/candy_wrapper/active_admin.rb
Normal file
9
lib/candy_wrapper/active_admin.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class ActiveAdmin::DSL
|
||||
def wrap_in_form_object
|
||||
controller do
|
||||
include CandyWrapper::InheritedResources
|
||||
|
||||
wrap_in_form_object!
|
||||
end
|
||||
end
|
||||
end
|
@ -55,6 +55,10 @@ module CandyWrapper
|
||||
end
|
||||
|
||||
def save
|
||||
if respond_to? :before_wrapped_save
|
||||
before_wrapped_save @__object__
|
||||
end
|
||||
|
||||
self.class.before_wrapped_save.each do |before|
|
||||
send("#{before}=", @__object__, @__params__[before])
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user