Я скачал шаблон Rails 3 + Mongoid + Devise и установил.
Я создал эшафот Автомобиль для связи с Пользователь модель Devise.У меня в модели User этот код:
class User
include Mongoid::Document
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
field :name
validates_presence_of :name
validates_uniqueness_of :name, :email, :case_sensitive => false
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
embeds_many :cars
end
и модель My Cars. У меня есть следующий код:
class Car
include Mongoid::Document
field :title
field :description
field :image_url
field :price
field :published_on, :type => Date
validates_presence_of :title, :description, :image_url, :price
validates :title, :length => { :maximum => 70 }
validates :description, :length => { :maximum => 2000 }
validates :price, numericality: {greater_than_or_equal_to: 0.01}
validates :image_url, allow_blank: true, format: {
with:
%r{\.(gif|jpg|png)$}i,
message: 'must be a URL for GIF, JPG or PNG image.'
}
embedded_in :user, inverse_of: :cars
end
Когда я обновляю страницу, я получаю следующую ошибку:
Mongoid :: Errors :: InvalidCollection in Cars # index
Доступ к коллекции автомобилей не разрешен, поскольку это встроенный документ, перейдите к коллекциииз корневого документа.
В чем проблема в этом коде?Thankyou