无法访问主干模型属性
我有一个董事会模型,其category_id代表类别父类,即一个类别有很多董事会。 我有一个以下的ruby模型
应用程序/模型/ board.rb
class Board < ActiveRecord::Base attr_accessible :description, :name, :open, :members, :category_id belongs_to :category end
只有我想通过在骨干模板标签标签中使用category_id(可访问)来获取类别对象。 如果我访问类别对象,我在label标签中变为null。
以下是很多代码,如果有更多需要我会发布。
骨干模型:
应用程序/资产/ Java脚本/模型/ board.js
Kanban.Models.Board = Backbone.RelationalModel.extend({ urlRoot: "/api/boards", relations: [{ type: Backbone.HasMany, key: "lists", relatedModel: "Kanban.Models.List", collectionType: "Kanban.Collections.Lists", reverseRelation: { key: "board" } },{ type: Backbone.HasMany, key: "users", relatedModel: "Kanban.Models.User", collectionType: "Kanban.Collections.Users" }] });
品类型号:
应用程序/资产/ Java脚本/模型/ category.js
Kanban.Models.Category = Backbone.RelationalModel.extend({ urlRoot: "/categories", relations: [{ type: Backbone.HasMany, key: "boards", relatedModel: "Kanban.Models.Board", collectionType: "Kanban.Collections.Boards", reverseRelation: { key: "category" } }] });
应用程序/视图/类别/ index.rabl
collection @categories attributes :id, :title, :description