我想覆盖与active_model_serializers
关联的kaminari
生成的分页链接。我如何实现这一点,this page没有关于覆盖的信息
此外,生成的链接按此顺序>> {" self"," first"," prev"," next"," last"}
我希望他们按此顺序代替>> {"首先"," prev"," self"," next"," last"}
以下是管理员控制器的索引方法片段:
def index
@search = Admin.search(params[:q])
if params[:page]
@admins = @search.result(:distinct => true).page(params[:page][:number])
else
@admins = @search.result(:distinct => true).page(1)
end
@admins_json = ActiveModel::SerializableResource.new(@admins)
@admins_json = @admins_json.to_json(serialization_context: ActiveModelSerializers::SerializationContext.new(request))
@page_entries_info = view_context.page_entries_info @admins
# render json: @admins
respond_to do |format|
format.html
format.js
format.json { render :json => @admins, meta: {:page_entries_info => @page_entries_info} }
end
end
答案 0 :(得分:0)
覆盖文件pagination_links.rb
将/home/vipin8169/.rvm/gems/ruby-2.2.3@rails426/bundler/gems/active_model_serializers-afe3c938070d/lib/active_model_serializers/adapter/json_api/pagination_links.rb
的内容复制到#lib/active_model_serializers/adapter/json_api/pagination_links.rb
并执行任何操作。