0
Тест Rails представил следующее предупреждение, когда я тестировал свою модель. Какие изменения нужно внести в мою модель,Предупреждение об отказе от Rails
rake test test/models/user.rb
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
DEPRECATION WARNING: The following options in your User.has_many :incoming_friends declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
. (called from <class:User> at /home/divya/projects/shufflejoy/app/models/user.rb:9)
и это моя модель пользователя,
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :user_name , :email, :first_name ,:last_name , :presence => true
has_many :invitations
has_many :incoming_friends , :class_name => "User" , :foreign_key=>"friend_id" , :through => :invitations, :conditions => ["status = 1"]
has_many :outgoing_friends , :class_name => "User" , :foreign_key=>"user_id", :through => :invitations, :conditions => ["status = 1"]
end
Я уже пробовал это, но он бросает ошибку ошибку синтаксис следующий синтаксис, неожиданный =>, ожидая «}» .. .tgoing_friends, -> {: status => '1'},: class_name => «Пользователь» ... –
Я использую 'where' внутри блока, вы, кажется, пропустили это. – depa
Спасибо, добавив «где»! –