Swiftype rails,post_url运行worker时未定义的方法



我正在尝试在Rails 3.2.5上实现Swiftype。但是,添加类别并运行rake jobs:work时,我收到以下错误消息:

CreateSwiftypeDocumentJob 失败,出现 NoMethodError: undefined 方法 "post_url"表示 #

CreateSwiftypeDocumentJob模型中,我有:

post = ProposalCategory.find(proposal_category_id) 
url = Rails.application.routes.url_helpers.post_url(post)

如果有人能帮忙,那将不胜感激。

post_url 只有在您实际上有 Post 资源的路由时才应使用。

您的routes.rb文件中有什么?大概是这样的:

resources :proposal_categories

在这种情况下,您需要使用类似 proposal_category_url .

相关内容

最新更新