2016-09-01 1 views
1

Je reçois cette erreur: ActionView :: Template :: Erreur: constante non initialisée ActsAsTaggableOn :: TagDashboard Voulez-vous dire? Je veux vraiment que ce soit UserDashboard mais je ne sais pas ce que j'ai besoin d'ajouter ci-dessous ou de modifier. Des idées? Merci beaucoup. Donc, j'ai mis en place mon gem Adminstrate, je suis capable de montrer mes modèles (y compris l'utilisateur). Mais quand je clique sur Modifier, j'obtiens l'erreur ci-dessus.Acts-As_Taggable & Administrer Gem - Constante non initialisée ActsAsTaggableOn :: TagDashboard

J'utilise les gemmes connexes suivants

ruby "2.3.1" 

gem "rails", "5.0.0.1" 

gem "pg", "0.18.4" # postgresql database 
gem "acts-as-taggable-on", git: "https://github.com/mbleigh/acts-as-taggable-on" # tagging 
gem "administrate", git: "https://github.com/heyogrady/administrate", branch: "rails5" 

Ci-dessous mon code:

enter code here`require "administrate/base_dashboard" 

class UserDashboard < Administrate::BaseDashboard 

    # ATTRIBUTE_TYPES 
    # a hash that describes the type of each of the model's fields. 
    # 
    # Each different type represents an Administrate::Field object, 
    # which determines how the attribute is displayed 
    # on pages throughout the dashboard. 
    ATTRIBUTE_TYPES = { 
    owned_taggings: Field::HasMany.with_options(class_name: "::ActsAsTaggableOn::Tagging"), 
    owned_tags: Field::HasMany.with_options(class_name: "::ActsAsTaggableOn::Tag"), 
    team_group: Field::BelongsTo, 
    lead_groups: Field::HasMany, 
... 
    } 

    # COLLECTION_ATTRIBUTES 
    # an array of attributes that will be displayed on the model's index page. 
    # 
    # By default, it's limited to four items to reduce clutter on index pages. 
    # Feel free to add, remove, or rearrange items. 
    COLLECTION_ATTRIBUTES = [ 
    :name, 
    :email, 
... 
    ] 

    # SHOW_PAGE_ATTRIBUTES 
    # an array of attributes that will be displayed on the model's show page. 
    SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys 

    # FORM_ATTRIBUTES 
    # an array of attributes that will be displayed 
    # on the model's form (`new` and `edit`) pages. 
    FORM_ATTRIBUTES = [ 
    :owned_taggings, 
    :owned_tags, 
    :team_group, 
    :lead_groups, 
... 
    ] 

    # Overwrite this method to customize how users are displayed 
    # across all pages of the admin dashboard. 
    # 
    def display_resource(user) 
    user.name 
    end 

end 

Répondre

0

Retirez simplement les lignes impliquant Tags dans ATTRIBUTE_TYPES comme ceci:

ATTRIBUTE_TYPES = { 
# taggings: Field::HasMany.with_options(class_name: "::ActsAsTaggableOn::Tagging"), 
# base_tags: Field::HasMany.with_options(class_name: "::ActsAsTaggableOn::Tag"), 
# tag_taggings: Field::HasMany.with_options(class_name: "ActsAsTaggableOn::Tagging"), 
# tags: Field::HasMany.with_options(class_name: "ActsAsTaggableOn::Tag"), 
# topic_taggings: Field::HasMany.with_options(class_name: "ActsAsTaggableOn::Tagging"), 
# topics: Field::HasMany.with_options(class_name: "ActsAsTaggableOn::Tag"), 
user: Field::BelongsTo, 
tag_list: Field::String, 
id: Field::Number, 
title: Field::String, 
body: Field::Text, 

également supprimer les lignes impliquant Tags au COLLECTION_ATTRIBUTES, SHOW_PAGE_ATTRIBUTES et FORM_ATTRIBUTES.

Si vous souhaitez afficher/modifier les balises sur un modèle, ajoutez cette ligne à ATTRIBUTE_TYPES:

tag_list: Field::String,

et vous pouvez maintenant utiliser :tag_list, dans COLLECTION_ATTRIBUTES, SHOW_PAGE_ATTRIBUTES et FORM_ATTRIBUTES.