我想用MongoMapper創建Rails 3引擎。我有一個讓人痛苦的世界。這是我的型號:用MongoMapper創建Rails引擎
module GoodComments
class Comment
include MongoMapper::Document
key :comment, String
end
end
超級簡單,我知道!我的config/routes.rb中:
GoodComments::Engine.routes.draw do
resources :comments
end
我創建了一個的config/application.rb中:
require File.expand_path('../boot', __FILE__)
module GoodComments
class Application < Rails::Application
config.generators do |g|
g.orm :mongo_mapper # :active_record
g.template_engine :erb # :haml
g.test_framework :rspec, :fixture => true, :views => false
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
end
end
我跑rails generate scaffold_controller Comment -o mongo_mapper
和生成我的控制器。當我運行我的服務器和去http://localhost:3000/good_comments/comments
,我得到一個錯誤:
LoadError在GoodComments :: CommentsController#指數
預計/Users/shamoon/Sites/good_comments/app/models/comment.rb定義評論 Rails.root:/ Users/shamoon/Sites/good_comments/test/dummy
任何幫助?
好吧..它那種工作,如果我擺脫了'模型中的GoodComments'命名空間。但scaffold'new'不讀取模型定義中的字段。 – Shamoon 2012-01-10 23:40:14