2011-05-17 34 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