-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to "undecorate" resource for forms #2085
Add option to "undecorate" resource for forms #2085
Conversation
options[:undecorate_with] = :model if options.delete(:undecorate) | ||
if (undecorate_method = options.delete(:undecorate_with)) | ||
resource = resource.send(undecorate_method) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These four lines of code are really hard to follow. It seems like all you want is this:
if should = options.delete :undecorate
resource = resource.send should==true ? :model : should
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daxter I agree, but does the api concept even make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the changes I made above removed the (unnecessary) undecorate_with
option, providing the same functionality through the undecorate
option.
Whether or not you adopt those changes, could you please explain what happens when you call .model
, and what sorts of other options someone might want to pass in?
Personally, I would rather see the simplest DSL: ActiveAdmin.register Post do
decorate_with PostsDecorator
form decorated: false, partial: 'form'
end Accept true/false & move on. Why would we need to accept a symbol as a method name to call on the decorator to get the original resource, if you can just get the resource from the decorator when you pass false in? Technically we are not tying you to Draper, but I think using the |
+1 on the |
@daxter @macfanatic that works for me, I like it. I just wasn't sure if the customized method call might be useful for something else... |
If such a time comes, we can always change it later :) On Apr 10, 2013, at 11:24 AM, Amiel Martin notifications@github.com wrote:
|
@daxter +1 for YAGNI. Ok, I'll change the documentation to include this, and I think it should be ready to go. |
Add option to "undecorate" resource for forms
Thanks guys! :) |
Thanks to you for putting in the effort |
This pull-request adds the following option:
This also adds more coverage for
ActiveAdmin::ViewHelpers::FormHelper.active_admin_form_for
(specs not specific to this pull-request).See discussion at #2057.