Skip to content

Instantly share code, notes, and snippets.

@Fivell
Created November 15, 2014 12:12
Show Gist options
  • Save Fivell/81921da21f3d92dc0d22 to your computer and use it in GitHub Desktop.
Save Fivell/81921da21f3d92dc0d22 to your computer and use it in GitHub Desktop.
AA Base decorator
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
@cpfarher
Copy link

cpfarher commented Sep 2, 2015

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?

@Fivell
Copy link
Author

Fivell commented Sep 2, 2015

@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