私はモデルを持っています
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :meetings, :dependent => :destroy do
def find_foreign
Meeting.where("user_id <> ?", id)
end
end
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
そして、そのようなユーザーの外国の会議を取得しようとしているとき
some_user.meetings.find_foreign
エラーが発生します
NoMethodError (undefined method `id' for []:ActiveRecord::Relation):
find_foreign の self は配列であるためです。このメソッドから User.id を取得する方法は?