Rails 添加视图有多难?

发布于 2024-12-08 18:12:23 字数 603 浏览 2 评论 0原文

这是我的错误:

路由错误

未初始化常量OverviewController

我是 Rails 新手,我不知道这意味着什么。我试图创建一个基于 URL 末尾“概述”的视图,有人向我展示了我认为所有内容都带有示例“admin”,这就像一个魅力。

我安装了 Rails 1.9(如果有影响的话)。

我的控制器“overview_controller.rb”位于控制器目录中。它的来源是。

class OverviewController < OverviewController
    def index
      respond_to do |format|
        format.html
      end
    end
end

我的视图目录中的overview/index.html.erb 其源代码更简单。 “概述占位符”就是这样。

在我的routes.rb中我有 匹配“概述”=> 根据我的理解, “overview#index”

与我得到的“admin”示例的工作方式完全相同。那么为什么这对我的“概述”不起作用

This is my Error:

Routing Error

uninitialized constant OverviewController

Im new to rails I have NO idea what this means. I am trying to create a view based on the end of the URL being "overview", someone showed me I thought everything with an example "admin" and that works like a charm.

I have rails 1.9 installed (if that makes a difference).

I have my controller "overview_controller.rb" in the controllers directory. The source of it being.

class OverviewController < OverviewController
    def index
      respond_to do |format|
        format.html
      end
    end
end

I have in my views directory overview/index.html.erb its source even simpler. "Overview Place Holder" thats it.

in my routes.rb I have
match "overview" => "overview#index"

this from my understanding is the same exact way the "admin" example I was given works. So why is it this isn't working for me with the "overview"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

|煩躁 2024-12-15 18:12:23

您试图通过自身对类进行子类化,将控制器的第一行更改为此...

class OverviewController < ApplicationController

You're trying to subclass the class by it's self, change the first line of your controller to this...

class OverviewController < ApplicationController
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文