Created
November 15, 2014 12:12
-
-
Save Fivell/81921da21f3d92dc0d22 to your computer and use it in GitHub Desktop.
AA Base decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseDecorator < Draper::Decorator | |
delegate_all | |
include Rails.application.routes.url_helpers | |
def arbre(&block) | |
Arbre::Context.new({}, self, &block).to_s #<<<--pass self as second argument | |
end | |
def comments_count | |
ActiveAdmin::Comment.where(resource_id: self.model.id.to_s, resource_type: self.model.class.to_s).count | |
end | |
end |
@cpfather, did you try to include ActionView::Helpers::NumberHelper
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think, there is another problem with this approach. Some helpers are not defined in arbre context. For example in https://gist.github.com/cpfarher/d96cdb0c4de617237c7e#file-recipe_recorator-rb-L16 .... is there any solution for this kind of problem?