2012-01-10 1 views
0

MongoMapper를 사용하여 레일즈 3 엔진을 만들려고합니다. 나는 고통의 세계를 가지고 가고 있습니다. 여기 내 모델 :MongoMapper로 레일즈 엔진 만들기

module GoodComments 
    class Comment 
    include MongoMapper::Document 

    key :comment, String 

    end 
end 

매우 간단, 나도 알아! 내 설정/routes.rb는 :

GoodComments::Engine.routes.draw do 
    resources :comments 
end 

내가 만든 설정/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를 실행하고 내 컨트롤러가 생성되었다. 정의 GoodComments에서

LoadError :: CommentsController 번호 지수

예상 /Users/shamoon/Sites/good_comments/app/models/comment.rb : 내 서버를 실행하고 http://localhost:3000/good_comments/comments에 갈 때, 오류가 발생합니다 Comment Rails.root :/사용자/shamoon/사이트/good_comments/test/dummy

도움이 필요하십니까?

+0

좋아 .. 그것은 일종의 내가 제거하면 작동하는' GoodComments' 네임 스페이스 모델에서. 그러나 scaffold'new'는 모델 정의의 필드를 읽지 않습니다. – Shamoon

답변

1

컨트롤러가 comment.rb에서 Comment라는 클래스를 예상 했으므로 컨트롤러가 동일한 모듈에서 작동해야 할 필요가있을 것 같습니다. 또는 기본 이외의 구성을 지정하거나 컨트롤러가 사용해야하는 모델에 대해 좀 더 구체적으로 지정해야합니다. 당신이 설정의 상단/application.rb에 추가보다 내 MongoMapper 응용 프로그램에서 또한

나는 몇 가지 더 라인을 가지고 :

require File.expand_path('../boot', __FILE__) 

# from http://mongomapper.com/documentation/getting-started/rails.html 
# replace: 
# require 'rails/all' 
# with: 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "active_resource/railtie" 
require "rails/test_unit/railtie" 
# Uncomment for asset pipelining in Rails 3.1 
# require "sprockets/railtie"