I'm using CarrierWave for my Avatar Uploading. The uploading and deletion of the avatar works in the user edit view and displays in otherviews. But when trying to include an Avatar with a comment I run into an error.
TypeError in CommentsController#create
can't cast AvatarUploader to string
app/controllers/comments_controller.rb:10:in `create'
I'm not sure what I've done wrong.
**comments_controller.rb**
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(comments_params)
@comment.user_name = current_user.user_name
@comment.avatar = current_user.avatar
if @comment.save
redirect_to @post
else
flash.now[:danger] = "error"
end
end
<%= comment.avatar %>` `
<%= comment.user_name %>
` `<%= comment.created_at %>
` `<%= comment.content %>
` – Merlin Jackson Mar 05 '15 at 03:54