active_adminの管理画面上からcategoryへアクセスできません
NoMethodError at /admin/categories
undefined method `except' for #Array:0x007f8302c92e58
lang
1 module Helpers 2 module Collection 3 # 1. removes `select` and `order` to prevent invalid SQL 4 # 2. correctly handles the Hash returned when `group by` is used 5 def collection_size(c = collection) 6 c = c.except :select, :order#ここに赤線が引かれている 7 c.group_values.present? ? c.count.count : c.count 8 end 9 def collection_is_empty?(c = collection)
lang
1# Category model 2 3class Category < ActiveRecord::Base 4 has_many :items 5 has_many :sub_categories, class_name: 'Category', foreign_key: 'parent_id' 6 belongs_to :categories, class_name: 'Category', foreign_key: 'parent_id' 7end 8 9 10 11#テーブルカラム 12class CreateCategories < ActiveRecord::Migration 13 def change 14 create_table :categories do |t| 15 t.integer :parent_id 16 t.string :name 17 t.string :code 18 19 t.timestamps 20 end 21 end 22end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。