我的 Rails 项目中有两个 JSON 文件
index.json.jbuilder
json.array! @restaurants, partial: 'restaurants/restaurant', as: :restaurant
和_restaurant.json.jbuilder
json.(restraurant, :id, :name, :address, :description)
当我在我的 index.html.erb 上渲染我的组件时
<%= react_component('RestaurantList', {name: raw(render(template: 'restaurants/index.json.jbuilder')) }) %>
我得到这个错误。
餐厅名称错误#index
undefined local variable or method `restraurant' for #<#<Class:0x007ffd1f6a61b0>:0x007ffd22e2bea0>
Did you mean? restaurant
restaurant_url
restaurant_path
restaurants_url
restaurants_path
@restaurants
Extracted source (around line #1):
1
json.(restraurant, :id, :name, :address, :description)
任何想法 ?