我正在實現屬於用戶訂閱的標籤的所有卡片的提要,並且出現以下錯誤。這可能是微不足道的,但我無法確定需要什麼工作。創建Feed => NoMethodError:未定義的ActiveRecord_Associations_CollectionProxy方法
NoMethodError:未定義的方法`卡標籤:: ActiveRecord_Associations_CollectionProxy:0x007fbaa46239f8>
這裏是我的模型:
class User < ActiveRecord::Base
has_many :cards, dependent: :destroy
has_many :tags, through: :cards
has_many :subscriptions, dependent: :destroy
has_many :subscribed_tags, through: :subscriptions, source: :tag
end
class Tag < ActiveRecord::Base
has_many :taggings, dependent: :destroy
has_many :cards, through: :taggings
has_many :subscriptions, dependent: :destroy
has_many :subscribers, through: :subscriptions, source: :user
end
class Card < ActiveRecord::Base
acts_as_votable
belongs_to :user
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
def self.tagged_with(name)
Tag.find_by_name!(name).cards
end
def self.tag_counts
Tag.select("tags.*, count(taggings.tag_id) as count").
joins(:taggings).group("taggings.tag_id")
end
def tag_list
tags.map(&:name).join(", ")
end
def tag_list=(names)
self.tags = names.split(",").map do |n|
Tag.where(name: n.strip).first_or_create!
end
end
end
什麼我真的想要做的是current_user.subscribed_tags.cards運行,檢索我可以重新排序並輸出爲時間線的卡片陣列。
感謝
要檢索的CURRENT_USER的subscribed_tags卡CURRENT_USER或數組的數組變量? – Astery
woops,typo:current_user的subscubed_tags卡片數組 – Ghost