我有以下型号:
Password = input("Please enter your password")
我有一个已过滤的用户列表,我按照这样的方式对列表进行分组:
class User < ActiveRecord::Base
belongs_to :room
end
class Room < ActiveRecord::Base
has_many :users
validates :name, presence: true
validates :location, presence: true
end
这给了我以下哈希:
users.group_by(&:room_id)
我想拥有一系列客房,包括他们的用户:
{
1=>[array of users belonging to room with id 1],
2=>[array of users belonging to room with id 2]
}