2

私はこれが以前に尋ねられたことを知っており、私のものに似ている多くの質問を見つけましたが、答えが同じ「タイプミス」であるように見えますが、コードを何度も何度も見て指摘できませんエラー/タイプミス、私はそれが単なるタイプミスではないと考え始めています: ファイル名の正確なスペルを含む私のコードは次のとおりです:

次の移行でテーブルを作成しました。

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

どなたか間違いを指摘していただけると大変助かります..

4

1 に答える 1

0

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
于 2012-08-06T22:48:26.070 に答える