Comment belongs_to Article, belongs to Question etc.
I need to return the path to Item, that has a comment in question.
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
def commentable_path
return case self.commentable_type
when "Article": article_path(self.commentable)
when "Question": question_path(self.commentable)
end
end
end
When article_path will be executed from Comment model, i get following error:
undefined method `article_path' for #
How to utilize routing helper methods from a model ?
Thanks.