在Ruby on Rails中通过Jbuilder构建JSON后,大小大于100的单个数组将变为多个数组

时间:2018-06-28 08:05:11

标签: ruby-on-rails arrays json reactjs jbuilder

我有一个包含100多个记录的表,当我尝试使用where方法检索记录时,得到的单个数组长度超过100。

但是在构建JSON并到达前端后,我得到两个数组而不是一个。一个数组的大小为100,另一个数组的其余元素。是因为jbuilder还是JSON有它可以保留的特定限制?

在控制器中

def index

    @screen_seat_type = ScreenSeatType.find_by screen_id: params[:screen_id], seat_type_id: params[:seat_type_id]
    @seats = Seat.where( :screen_seat_type_id => @screen_seat_type.id ).order(:name)

  end

在index.json.jbuilder中

json.seats @seats do |seat|
    json.id seat.id
    json.name seat.name
    json.row_name seat.row_name
    json.is_open seat.is_open
end

我正在使用Rails API + ReactJS。

1 个答案:

答案 0 :(得分:1)

在网络日志中,您看到两个数组,因为它会截断任何大数组,并且任何人都想查看整个数组,那么他可以扩展该数组。其实只有一个数组而不是两个