【发布时间】:2012-01-10 23:28:30
【问题描述】:
我正在尝试使用 MongoMapper 创建一个 Rails 3 引擎。我正在经历一个痛苦的世界。这是我的模型:
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 时,我收到一个错误:
GoodComments::CommentsController#index 中的加载错误
预期 /Users/shamoon/Sites/good_cmets/app/models/comment.rb 来定义评论 Rails.root: /Users/shamoon/Sites/good_cmets/test/dummy
有什么帮助吗?
【问题讨论】:
-
好的.. 如果我摆脱模型中的
GoodComments命名空间,它会起作用。但是脚手架new不会读取模型定义中的字段。
标签: ruby-on-rails-3 mongomapper