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
控制器对于这个类
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
如果有的话我真的很感激有错误的可以指出来..
I know this has been asked before and I have found many questions that are similar to mine but ever where the answer seems to be the same 'a typo', but I've looked at my code time and time again and can't point the error/typo out, I'm beginning to think its more then just a typo: here's my code with exact spellings for file names:
i created the table with the following migration:
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
Controller for this class
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
Since im using this for ActiveScaffold here's a snippet from 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
and this is what I used for my routes
resources :manage_site_configurations do as_routes end
I'd really appreciate it if some one can point the error out..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经进行了迁移,但是您是否在 app/models/ 中生成了模型,
否则可能应该
是
至少在 https://github.com/activescaffold/active_scaffold/wiki/getting-started
You have the migration, but do you have the model in app/models/ generated by
Otherwise it could be that
should be
At least they don't pluralize ':company' in the example on https://github.com/activescaffold/active_scaffold/wiki/getting-started