2011-05-17 84 views
4

我在我的应用程序中命名了我的模型和控制器。“模块不缺少常量模型” - Rails 3错误

,当我试图访问管理/ stories.html空间(namespace ::管理:: StoriesController)

我不断收到一个错误 “命名空间不缺定的故事!”

这里是供参考我的控制器的一个副本:

class NameSpace::Admin::StoriesController < NameSpace::ApplicationController 

    layout "admin" 
    before_filter :admin_login_required 

    cache_sweeper NameSpace::StorySweeper, :only => [:update,:destroy] 

    # expose is provided by the DecentExposure Gem 
    expose(:stories) { current_place.stories.where(:state => %w{ submitted published }).order("created_at DESC").page(params[:page]).per(25) } 
    expose(:story) 

    def create 
    if params[:success] == "1" 
     Story.find_or_create_by_media_id(params[:media_id])  
     redirect_to admin_stories_url, :notice => "Successfully created story! It should appear here in a few minuntes once it's been processed." 
    else 
     flash.now[:error] = "There was an error when creating your story!<br>If this happens again, please contact [email protected]#{APP_CONFIG[:domain]}".html_safe 
     render :new 
    end 
    end 

    def index 
    end 

    def show 
    end 

    def new 
    end 

    def edit 
    end 

    def update 
    if story.update_attributes(params[:story]) 
     redirect_to admin_stories_url, :notice => "Successfully updated story." 
    else 
     render :action => 'edit' 
    end 
    end 

    def destroy 
    story.remove! 
    redirect_to admin_stories_url, :notice => "Story successfully destroyed!" 
    end 

end 

我使用Rails 3.1.0.beta1与REE

回答

0

这是一个Rails错误

通过更新定额Rails/Master @ github上最新版本的Rails 3.1.0.beta1。

# Gemfile 
gem "rails", :git => "git://github.com/rails/rails.git" 

然后

bundle install 
+1

呸,具体的错误或原因,一些信息,这将是有助于将来参(得到这个是Rails的2.3.11) – ghayes 2011-09-04 06:26:54

+1

同意 - 您可以加入更多一些关于你如何跟踪这个信息?谢谢! – rusty 2011-09-08 18:42:12

+0

抱歉的家伙 - 我确定它是对github问题之一的评论 - 可能来自JoshPeek,建议升级到出血性边缘。该解决方案为我工作,所以我没有深入挖掘。祝你好运 – bodacious 2011-09-11 20:18:58

1

使用的module代替冒号符号类名来表示命名空间的固定问题,我在Rails的3.0.15

例如

module Foo 
    class Bar 
    ... 
    end 
end 

VS

class Foo::Bar 
end