我已经在我的应用程序中命名了我的模型和控制器。
当我尝试访问admin / stories.html(NameSpace :: Admin :: StoriesController)
时我一直收到错误“NameSpace不会错过常数故事!”
这是我的控制器的副本供参考:
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 support@#{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 :(得分:1)
使用module
而不是类名的冒号表示来表示命名空间在Rails 3.0.15中修复了我的问题
e.g。
module Foo
class Bar
...
end
end
VS
class Foo::Bar
end
答案 1 :(得分:0)
这是一个Rails错误
通过在Rails / Master @ github上更新到最新版本的Rails 3.1.0.beta1来解决。
# Gemfile
gem "rails", :git => "git://github.com/rails/rails.git"
然后
bundle install