I have a function called update_status inside my comments_controller.rb:
def update_status
@comment.relative_value = @comment.points_up - @comment.points_down
randomize!
end
Where @comment = Comment.find(params[:id])
Because of the way I've set up the website, I want to be able to call c.update_status for any comment c. For example, in my posts_controller, I want to be able to do this:
def show
@posts = Post.order('trending_value DESC').page(params[:page]).per(5)
@post = Post.find(params[:id])
@comments = @post.comments
@comments.each do |c| #TODO: FIX
c.update_status
c.save
end
end
How do I get this to work? I keep getting undefined method error for # < Comment >. Do I have to do def self.update_status? That didn't seem to work either.