I have used draper gem to generate the decorator and I have crated a decorators. I have used namespacing inside decorator folder, and I tried to access the that decorator in specific controller with decorates_assigned.
For example my folder structure is decorators/admin/example_decorator.rb
And I have added the following line in controller:
decorates_assigned :example
and in action I have written
def edit
@example = Admin::ExampleDecorator.new(Example.last)
end
But I am getting following error:
Could not infer a source for Admin::ExampleDecorator.
I am not understanding why this error is coming.
How namespaces are works in Decorator?
I am not entirely sure about your question, but since you are using
decorated_assigned :example
you are creating a helper method. See the Draper readme.You won't need to call the decorator explicitely.
This means in your view you will call
example
instead of@example
to get the decorated version. This will call your helper method and returns the decorated version.