mercredi 14 septembre 2016

NameError in Admin::Recommandations#index

I have multiple ressources on my ActiveAdin interface, one of them returns me an error when i go on the Index view "/admin/recommandations" with the following message :

NameError in Admin::Recommandations#index 
Showing /home/charles/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-0a5a15b88bff/app/views/active_admin/resource/index.html.arb where line #2 raised: 
uninitialized constant Recommandation::Writer

The recommendation functionality is simple : one user can rate an other user by making a recommendation. In my Recommandation model I have one user (the one who is rated) and a Writer (the one who write the recommendation).

Recommandation model :

class Recommandation < ActiveRecord::Base
  before_validation:check_models

  belongs_to :user
  validates :user_id, presence: true
  validates_associated :user

  # Il s'agit de l'utilisateur qui inscrit la recommandation
  has_one :writer, :foreign_key => "writer_id" 
  validates :writer_id, presence: true
  validates_associated :writer

  validates :modele, presence: true

  ##
  # @return L'origine liée
  def writer
    if self.writer_id != nil
      User.find(self.writer_id)
    end
  end

I can access each of my Recommandation ressources with "/admin/recommandations/1" and there is a writer which is a user so I don't understand where the problem is.

Aucun commentaire:

Enregistrer un commentaire