我将此方法作为自动填充文本字段的来源。
def index
@articulos = Articulo.where("descripcion ILIKE CONCAT('%',?,'%')",params[:term]).
or(Articulo.where("codigo ILIKE CONCAT('%',?,'%')",params[:term]))
render json: @articulos.map(&:descripcion)
end
此查询按说明或Codigo搜索,但JSON在自动填充字段中仅显示说明。我需要JSON在自动填充文本字段中显示连接的Codigo属性和描述,例如
34432 - descripcion del articulo