Rails draper gem with Ajax/JS

147 views Asked by At

I'm using draper and want to use one of the decorators in a view.

With HTML everything works, but decorators don't work in the Ajax version - I get an undefined method error.

In CommentDecorator:

delegate_all

def comment_author
  "#{user.firstname} #{user.lastname}"
end

In view:

comment.comment_author

I'm using exposure, so I don't need instance variables in views.

1

There are 1 answers

0
Viktor Leonets On BEST ANSWER

you can use comment.decorate.comment_author