2011-06-17 92 views
2

我知道这已被问及之前,我发现了很多类似于我的问题,但答案似乎是相同的'一个错字',但我看着我代码时间和时间再次,并不能指出错误/错字,我开始认为它不仅仅是一个错字:这是我的代码与文件名的确切拼写:Rails3:路由错误未初始化的常量SiteConfiguration

我创建了以下表迁移:

015_create_site_configurations.rb

class CreateSiteConfigurations < ActiveRecord::Migration 

    def self.up 
    create_table "site_configurations" do |t| 
     t.column :config_type, :string 
     t.column :value,   :string 

    end 

    end 

    def self.down 
    drop_table "site_configurations" 
    end 
end 
01这里

控制器该类

manage_site_configurations_controller.rb

class ManageSiteConfigurationsController < AdminController 

    active_scaffold :site_configurations do |config| 
    config.columns = [:config_type, :value] 
    config.create.columns = [:config_type, :value] 
    end 

end 

因为即时通讯使用这种用于ActiveScaffold是从application.rb中

def self.active_scaffold_controller_for(klass) 
    return ManageUsersController if klass == User 
    return ManagePagesController if klass == Page 
    return ManageSiteConfigurationsController if klass == SiteConfiguration 
    return "#{klass}ScaffoldController".constantize rescue super 
    end 

一个片段,这就是我用于我的路线

resources :manage_site_configurations do as_routes end 

我真的很感激,如果有人可以指出错误了..

回答

0

你有迁移,但你必须在应用程序/模型/由

rails g active_scaffold Model attr1:type attr2:type 
rake db:migrate 
生成的模型

否则它可能是

active_scaffold :site_configurations do |config| 

应该

active_scaffold :site_configuration do |config| 
在例如在 https://github.com/activescaffold/active_scaffold/wiki/getting-started

active_scaffold :company do |config| 
    config.label = "Customers" 
    config.columns = [:name, :phone, :company_type, :comments] 
    list.columns.exclude :comments 
    list.sorting = {:name => 'ASC'} 
    columns[:phone].label = "Phone #" 
    columns[:phone].description = "(Format: ###-###-####)" 
end 

至少他们不以复数“公司”