Ruby on Rails中未初始化的控制器常量5

时间:2017-06-29 17:55:14

标签: ruby-on-rails ruby

我得到uninitialized constant Project::Controller。我在SO上查看了Rails文档和帖子,但代码似乎设置正确。我正在使用rails 5.1.1。我的页面路径工作正常,只有根路径给出错误。

路线.rb

Rails.application.routes.draw do

  devise_for :admin_users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
  devise_for :users,
             path: '',
             path_names: {
                 sign_in: 'login',
                 sign_out: 'logout',
                 edit: 'profile'
             },
             controllers: { omniauth_callbacks: 'omniauth_callbacks' }

  get 'pages/about'

  root 'project/#index'

  resources :project do
    resources :task, only: [:show]
  end

end

project_controller.rb

class ProjectController < ApplicationController
  def index
    @projects = Project.all
  end

  def show
    @project = Project.find(params[:id])
    @tasks = @project.tasks
  end
end

1 个答案:

答案 0 :(得分:1)

更改

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Campaign>()
        .Property<string>("ExtendedDataStr")
        .HasField("_extendedData");
}

root 'project/#index'