«Модуль не пропускает постоянную модель» - ошибка Rails 3 - PullRequest
4 голосов
/ 17 мая 2011

Я поместил в моём приложении пространство имен и моделей моих контроллеров.

, когда я пытаюсь посетить admin / Stories.html (NameSpace :: Admin :: StoriesController)

Я получаю ошибку«NameSpace не пропускает постоянную Story!»

вот копия моего контроллера для справки:

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

Ответы [ 2 ]

1 голос
/ 05 августа 2012

Использование module вместо двоеточия для имени класса для обозначения пространства имен устранило проблему для меня в Rails 3.0.15

, например

module Foo
  class Bar
  ...
  end
end

против

class Foo::Bar
end
0 голосов
/ 18 мая 2011

Это была ошибка Rails

Исправлено путем обновления до последней версии Rails 3.1.0.beta1 на Rails / Master @ github.

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

затем

bundle install
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...