1
3引擎的問題,我有一個發動機,與此路線文件:導軌和路線
Rails.application.routes.draw do
resources :comments, :controller => 'opinio/comments'
end
當我運行rake routes
任務,我得到正確的輸出
comments GET /comments(.:format) {:action=>"index", :controller=>"opinio/comments"}
POST /comments(.:format) {:action=>"create", :controller=>"opinio/comments"}
new_comment GET /comments/new(.:format) {:action=>"new", :controller=>"opinio/comments"}
edit_comment GET /comments/:id/edit(.:format) {:action=>"edit", :controller=>"opinio/comments"}
comment GET /comments/:id(.:format) {:action=>"show", :controller=>"opinio/comments"}
PUT /comments/:id(.:format) {:action=>"update", :controller=>"opinio/comments"}
DELETE /comments/:id(.:format) {:action=>"destroy", :controller=>"opinio/comments"}
我的控制器是非常簡單的:
class Opinio::CommentsController < ApplicationController
include Opinio::Controllers::InternalHelpers
def index
resource.comments.page(params[:page])
end
def create
@comment = resource.comments.build(params[:comment])
@comment.user = current_user
if @comment.save
flash[:notice] = I18n.translate('opinio.comment.sent', :default => "Comment sent successfully.")
else
flash[:error] = I18n.translate('opinio.comment.error', :default => "Error sending the comment.")
end
end
end
但是,當我嘗試使用任何行動去引擎的控制器我得到以下錯誤:
uninitialized constant Comment::CommentsController
我真誠地不知道在哪裏的Rails奇蹟般地在控制器上添加此Comment
命名空間,我沒有對如何解決這個問題的線索。