开发者

Rails3: Routing Error uninitialized constant SiteConfiguration

I know this has been asked before and I have found many questions that are similar to mine but ever where t开发者_如何学Gohe 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..


You have the migration, but do you have the model in app/models/ generated by

rails g active_scaffold Model attr1:type attr2:type
rake db:migrate

Otherwise it could be that

active_scaffold :site_configurations do |config|

should be

active_scaffold :site_configuration do |config|

At least they don't pluralize ':company' in the example on 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜