我想使用 rails URL helper 而不是硬编码访问文章的路径。
我检查了文档,但没有指定任何内容。
article_path
辅助方法存在(我通过运行检查rake routes
)
class V3::ArticlesController < Api::V3::BaseController
def index
articles = Article.all
render json: ::V3::ArticleItemSerializer.new(articles).serialized_json
end
end
class V3::ArticleItemSerializer
include FastJsonapi::ObjectSerializer
attributes :title
link :working_url do |object|
"http://article.com/#{object.title}"
end
# link :what_i_want_url do |object|
# article_path(object)
# end
end